Fixed variable name issue in remove.background function

This commit is contained in:
Marijn 2020-06-08 10:15:27 +02:00
parent 40765c3a42
commit f4b6748210
1 changed files with 2 additions and 2 deletions

View File

@ -31,13 +31,13 @@ remove.background = function(geneCellMatrix, ambientRNAprofile){
# Here is the actual functionality
for(gene in names(ambientProfile[ambientProfile > 0])){
for(gene in names(ambientRNAprofile[ambientRNAprofile > 0])){
# Determine the locations where the gene is not zero, therefore referenced in i
iLocs = which(geneCellMatrix@Dimnames[[1]] == gene)
# Determine the location of the actual values,
xLocs = which(geneCellMatrix@i == iLocs-1) # -1 because of 0 and 1 based counting systems
# Remove the contaminating RNA
geneCellMatrix@x[xLocs] = geneCellMatrix@x[xLocs] - ambientProfile[gene]
geneCellMatrix@x[xLocs] = geneCellMatrix@x[xLocs] - ambientRNAprofile[gene]
}
# correct for instances where the expression was corrected to below zero
geneCellMatrix@x[geneCellMatrix@x < 0] = 0