Danko-Lab / TED

a fully Bayesian approach to deconvolve tumor microenvironment
60 stars 10 forks source link

Error during correct batch effect #6

Closed t-carroll closed 4 years ago

t-carroll commented 4 years ago

Hello, I've just started trying out this package, but have encountered the following bug during the "correct batch effect" phase of run.Ted:

Error in if (d2 == 0L) { : missing value where TRUE/FALSE needed

Googling this error message suggests it is thrown when an incorrect margin argument is given to apply (see: https://stackoverflow.com/questions/38241894/error-in-setting-bin-grouping-using-cut-error-in-if-d2-0l-missing-value). I've just searched through your code here, and I see this line:

Zkg.tum <- apply(first.gibbs.res$Znkg[, tum.idx,],c(1,3),sum)

So a margin argument of c(1,3) is provided to apply, whereas I think only 1, 2, or c(1,2) are acceptable as margin values.

Please let me know if you need more info on my environment- I am getting this error both when I run with single-core execution on my Windows machine and with multi-core execution on our Linux cluster (both from Rstudio).

tinyi commented 4 years ago

Thank you for your feedback. Could you kindly provide me with 1) the exact argument for calling the run.Ted function 2) the dimension of ref.dat and X, 3) the rownames(ref.dat).

Best,

Tinyi

On Sun, Apr 12, 2020 at 11:29 AM t-carroll notifications@github.com wrote:

Hello, I've just started trying out this package, but have encountered the following bug during the "correct batch effect" phase of run.Ted:

Error in if (d2 == 0L) { : missing value where TRUE/FALSE needed

Googling this error message suggests it is thrown when an incorrect margin argument is given to apply (see: https://stackoverflow.com/questions/38241894/error-in-setting-bin-grouping-using-cut-error-in-if-d2-0l-missing-value). I've just searched through your code here, and I see this line:

Zkg.tum <- apply(first.gibbs.res$Znkg[, tum.idx,],c(1,3),sum)

So a margin argument of c(1,3) is provided to apply, whereas I think only 1, 2, or c(1,2) are acceptable as margin values.

Please let me know if you need more info on my environment- I am getting this error both when I run with single-core execution on my Windows machine and with multi-core execution on our Linux cluster (both from Rstudio).

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Danko-Lab/TED/issues/6, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB4NHS2N2EOFA6BA65QP77TRMHM55ANCNFSM4MGOQPQQ .

t-carroll commented 4 years ago

Hi Tinyi, here's the requested info:

ted_maag = run.Ted(ref.dat = subgroup, X = maag, pheno.labels = cells, n.cores=1, tum.key = "Non_Squamous_Epithelium", input.type="scRNA",pdf.name = "test.pdf")

Dim of ref.dat (subgroup): nrow(subgroup) [1] 3440 ncol(subgroup) [1] 21837

Dim of X (maag): nrow(maag) [1] 63 ncol(maag) [1] 20083

The rownames of ref.dat are a bit long but are of the format (first 4): "Fibroblast" "Fibroblast.1" "Fibroblast.2" "Fibroblast.3"......

Could rougly replicate the full list of rownames with the following function: cells = c("B_cell","CD4_Tcell","CD8_Tcell","Dendritic_cell","Fibroblast","Lymphatic_Endothelium","Mast_cell","Monocyte_Macrophage","Myofibroblast","Neutrophil","NK_cell","Non_Squamous_Epithelium","Plasma_cell","Squamous","Treg","Vascular_Endothelium") x = vector(mode = "character") for(i in 1:length(cells)){x = c(x,paste(cells[i],1:214,sep="."))} x = c(x,cells) x = x[order(x)]

Let me know if you need more info, thanks!

tinyi commented 4 years ago

Thank you for your information. I have now fixed the bug. It is caused by having only one tumor phenotype, in which case R automatically dropped the dimension.

Usually we recommend users to provide tumor references from multiple patients / subclusters to account for heterogeneity. In some cases, users would like to apply TED on non-tumorous conditions, and hence treat each reference equally. In this case, one may simply set tumor.key=NULL.

Let me know if you have any questions.

Best,

Tinyi

On Mon, Apr 13, 2020 at 7:12 AM t-carroll notifications@github.com wrote:

Hi Tinyi, here's the requested info:

ted_maag = run.Ted(ref.dat = subgroup, X = maag, pheno.labels = cells, n.cores=1, tum.key = "Non_Squamous_Epithelium", input.type="scRNA", pdf.name = "test.pdf")

Dim of ref.dat (subgroup): nrow(subgroup) [1] 3440

ncol(subgroup) [1] 21837

The rownames of ref.dat are a bit long but are of the format (first 4): "Fibroblast" "Fibroblast.1" "Fibroblast.2" "Fibroblast.3"......

Could rougly replicate the full list of rownames with the following function: cells = c("B_cell","CD4_Tcell","CD8_Tcell","Dendritic_cell","Fibroblast","Lymphatic_Endothelium","Mast_cell","Monocyte_Macrophage","Myofibroblast","Neutrophil","NK_cell","Non_Squamous_Epithelium","Plasma_cell","Squamous","Treg","Vascular_Endothelium") x = vector(mode = "character") for(i in 1:length(cells)){x = c(x,paste(cells[i],1:214,sep="."))} x = c(x,cells) x = x[order(x)]

Let me know if you need more info, thanks!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Danko-Lab/TED/issues/6#issuecomment-612857575, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB4NHS2P557UT5DLWHGQV2LRMLXTHANCNFSM4MGOQPQQ .

t-carroll commented 4 years ago

Hi Tinyi,

Thanks for the quick update! I will go back to update the tumor labels with patient IDs/subclustering as I continue to explore this tool. I can verify that this fix worked on my end too, and the command now completes successfully.

However, I did also previously try running run.Ted() with tum.key = NULL, but got the following error, which persists in the new code: ted_maag = run.Ted(ref.dat = subgroup, X = maag, pheno.labels = cells, n.cores=1,tum.key = NULL, input.type="scRNA",pdf.name = "test.pdf") [1] "removing non-numeric genes..." [1] "removing outlier genes..." Number of outlier genes filtered= 3 [1] "aligning reference and mixture..." Error in run.Ted(ref.dat = subgroup, X = maag, pheno.labels = cells, n.cores = 1, : !is.null(tum.key) is not TRUE

I've submitted a pull request (https://github.com/Danko-Lab/TED/pull/7/commits/c7cb07925a38f76cde377c19cacdd9c8991fa83a) that removes the line of code that throws that error and allows the command to complete successfully for input.type="scRNA" and tum.key=NULL (if this is an acceptable use case for this algorithm).

tinyi commented 4 years ago

Thank you very much for the suggestion. Yes. Good catch. That assertion should be removed to allow for non-tumorous cases. Many thanks.

Best,

Tinyi

On Tue, Apr 14, 2020 at 10:46 AM t-carroll notifications@github.com wrote:

Hi Tinyi,

Thanks for the quick update! I will go back to update the tumor labels with patient IDs/subclustering as I continue to explore this tool. I can verify that this fix worked on my end too, and the command now completes successfully.

However, I did also previously try running run.Ted() with tum.key = NULL, but got the following error: `ted_maag = run.Ted(ref.dat = subgroup, X = maag, pheno.labels = cells, n.cores=1,

-

              tum.key = NULL, input.type="scRNA",pdf.name = "test.pdf")`

[1] "removing non-numeric genes..." [1] "removing outlier genes..." Number of outlier genes filtered= 3 [1] "aligning reference and mixture..." Error in run.Ted(ref.dat = subgroup, X = maag, pheno.labels = cells, n.cores = 1, : !is.null(tum.key) is not TRUE

This error still remains even with the updated code. I've submitted a pull request (c7cb079 https://github.com/Danko-Lab/TED/commit/c7cb07925a38f76cde377c19cacdd9c8991fa83a) that removes the line of code and allows the command to complete successfully for input.type="scRNA" and tum.key=NULL (if this is an acceptable use case for this algorithm).

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Danko-Lab/TED/issues/6#issuecomment-613485832, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB4NHS6KMSNQEX3R6AKMMYTRMRZKLANCNFSM4MGOQPQQ .

t-carroll commented 4 years ago

no problem, thank you!