constantAmateur / SoupX

R package to quantify and remove cell free mRNAs from droplet based scRNA-seq data
254 stars 35 forks source link

toc data in strainChannel.R #1

Closed aheilbut closed 6 years ago

aheilbut commented 6 years ago

First, thank you for making SoupX -- the method is elegant, and it seems to work very nicely!

I couldn't get strainChannel to work until I made this little fix to make sure that toc was actually defined inside the function:

diff --git a/R/strainChannel.R b/R/strainChannel.R
index 82a4a09..d4f36d3 100644
--- a/R/strainChannel.R
+++ b/R/strainChannel.R
@@ -20,6 +20,7 @@ strainChannel = function(tod,cellIdxs,nonExpressedGeneList,soupRange=c(0,10),...
   trueCellExpression = strainCells(tod[,cellIdxs],cellRhos,soupProfile)
   #And also calculate the ratio of the observed counts to the soup.  Kept un-logged so it remains sparse
   #We should really convert a bunch of 0s to NaNs, but don't do this to save space.
+  toc <- tod[, cellIdxs]
   expressionRatio = t(t(toc)/colSums(toc))
   expressionRatio@x = expressionRatio@x/soupProfile[expressionRatio@i+1,'est']
   #Now return everything that we've calculated
constantAmateur commented 6 years ago

Thank you very much for spotting the bug! I've overhauled the way the code is structured to make the intermediate steps more transparent. In the process I've removed the strainChannel function, otherwise I'd incorporate your change into the code.

Hopefully it's still fairly easy to follow. Unfortunately it'll mean you'll have to get used to how the package works all over again.