TED icon indicating copy to clipboard operation
TED copied to clipboard

Error in rmultinom

Open xzhouaw opened this issue 2 years ago • 5 comments

Thanks for the useful deconvolution tool. I am trying to use TED to deconvolute bulk RNA-seq data from tissues. And I used raw reads for scRNA-seq and expected counts generated from RSEM for bulk RNA-seq as input to run TED. However, I got the error as the following:

[1] "removing non-numeric genes..."
[1] "removing outlier genes..."
Number of outlier genes filtered= 7 
[1] "aligning reference and mixture..."
[1] "No tumor reference is speficied. Reference profiles are treated equally."
[1] "run first sampling"
current sample ID:1  Error in rmultinom(n = 1, size = X.i[g], prob = prob.mat[, g]) : 
  invalid second argument 'size'
Calls: run.Ted ... draw.sample.gibbs -> mclapply -> lapply -> FUN -> sample.n -> rmultinom
Execution halted

Here is my code : library(TED)

ref.dat <- read.csv("scRNA-counts-for.t-for.csv", header=TRUE, row.names=1, sep="\t")
X <- read.csv("placenta_genename-count.uniq.t.for.csv", header=TRUE, row.names=1, sep="\t")
cell.type <- read.csv("scRNA-celltype-for.csv", header=FALSE, sep="\t")
cell.type.labels <- cell.type[[1]]
run.Ted(ref.dat, X, cell.type.labels, input.type="scRNA", pdf.name="trail.pdf")

Is there any suggestion about this error? Thanks~

xzhouaw avatar Aug 22 '21 17:08 xzhouaw

Could you print the head(rownames(ref.dat)), head(colnames(ref.dat)), head(rownames(X)), head(colnames(X)) ? I suspect that it might be caused by an unmatched input data format.

Thanks.

On Sun, Aug 22, 2021 at 1:41 PM xzhouaw @.***> wrote:

Thanks for the useful deconvolution tool. I am trying to use TED to deconvolute bulk RNA-seq data from tissues. And I used raw reads for scRNA-seq and expected counts generated from RSEM for bulk RNA-seq as input to run TED. However, I got the error as the following:

[1] "removing non-numeric genes..." [1] "removing outlier genes..." Number of outlier genes filtered= 7 [1] "aligning reference and mixture..." [1] "No tumor reference is speficied. Reference profiles are treated equally." [1] "run first sampling" current sample ID:1 Error in rmultinom(n = 1, size = X.i[g], prob = prob.mat[, g]) : invalid second argument 'size' Calls: run.Ted ... draw.sample.gibbs -> mclapply -> lapply -> FUN -> sample.n -> rmultinom Execution halted

Here is my code : library(TED)

ref.dat <- read.csv("scRNA-counts-for.t-for.csv", header=TRUE, row.names=1, sep="\t") X <- read.csv("placenta_genename-count.uniq.t.for.csv", header=TRUE, row.names=1, sep="\t") cell.type <- read.csv("scRNA-celltype-for.csv", header=FALSE, sep="\t") cell.type.labels <- cell.type[[1]] run.Ted(ref.dat, X, cell.type.labels, input.type="scRNA", pdf.name="trail.pdf")

Is there any suggestion about this error? Thanks~

— 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/13, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB4NHSYXPZFAPVSLVUSXSHLT6EZFJANCNFSM5CTFCUYA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

tinyi avatar Aug 23 '21 00:08 tinyi

Thanks for your fast reply. Here is the result:

> head(rownames(X))
[1] "X20210128.RNA.Cov1"  "X20210128.RNA.Cov2"  "X20210128.RNA.Cov3" 
[4] "X20210128.RNA.Ctrl1" "X20210128.RNA.Ctrl2" "X20210128.RNA.Ctrl3"
> head(colnames(X))
[1] "A1BG"     "A1BG.AS1" "A1CF"     "A2M"      "A2M.AS1"  "A2ML1"  
> head(rownames(ref.dat))
[1] "Ctrl2_AAACCCAAGAGGTGCT.1" "Ctrl2_AAACCCAGTGAACGGT.1"
[3] "Ctrl2_AAACGAAAGCACACAG.1" "Ctrl2_AAACGAAAGGGTGGGA.1"
[5] "Ctrl2_AAACGAAGTATCCCAA.1" "Ctrl2_AAACGCTAGGGCTTCC.1"
> head(colnames(ref.dat))
[1] "AL627309.1" "AL627309.3" "AL627309.5" "AL627309.4" "AP006222.2"
[6] "AL732372.1"

xzhouaw avatar Aug 23 '21 03:08 xzhouaw

I suspect that it was caused by the issue that your input was dataframe rather than matrix type. Try converting them to matrix using as.matrix.

On Sun, Aug 22, 2021 at 11:54 PM xzhouaw @.***> wrote:

Thanks for your fast reply. Here is the result:

head(rownames(X)) [1] "X20210128.RNA.Cov1" "X20210128.RNA.Cov2" "X20210128.RNA.Cov3" [4] "X20210128.RNA.Ctrl1" "X20210128.RNA.Ctrl2" "X20210128.RNA.Ctrl3" head(colnames(X)) [1] "A1BG" "A1BG.AS1" "A1CF" "A2M" "A2M.AS1" "A2ML1" head(rownames(ref.dat)) [1] "Ctrl2_AAACCCAAGAGGTGCT.1" "Ctrl2_AAACCCAGTGAACGGT.1" [3] "Ctrl2_AAACGAAAGCACACAG.1" "Ctrl2_AAACGAAAGGGTGGGA.1" [5] "Ctrl2_AAACGAAGTATCCCAA.1" "Ctrl2_AAACGCTAGGGCTTCC.1" head(colnames(ref.dat)) [1] "AL627309.1" "AL627309.3" "AL627309.5" "AL627309.4" "AP006222.2" [6] "AL732372.1"

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/Danko-Lab/TED/issues/13#issuecomment-903421191, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB4NHS26M7J3FIOMKMYNW43T6HBA3ANCNFSM5CTFCUYA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

tinyi avatar Aug 24 '21 12:08 tinyi

Thanks! I used the following code to convert them to matrix and then the problem disappeared.

ref.dat <- data.matrix(read.csv("scRNA-counts-for.t-for.csv", header=TRUE, row.names=1, sep="\t"))
X <- data.matrix(read.csv("placenta_genename-count.uniq.t.for.csv", header=TRUE, row.names=1, sep="\t"))

I am pretty new to R language, so after I got the result, I am not sure how to extract the cell proportion of each sample and the gene expression to a new file now. I used the followed code, but it reminded "Error: object 'res' not found".

fraction_1 <- res$first.gibbs.res$gibbs.theta
write.csv(fraction_1, "initial_fraction.csv")
fraction_2 <- res$first.gibbs.res$theta.merged
write.csv(fraction_2, "summed_fraction.csv")
expression_1 <- res$first.gibbs.res$Znkg
write.csv(expression_1, "initial_expression.csv")
expression_2 <- res$first.gibbs.res$Znkg.merged
write.csv(expression_2, "summed_expression.csv")

By the way, this is the part of the result, is it the proportion of each cell types of different sample? Do I understand properly?

$res$first.gibbs.res$theta.merged
                                   Fibroblast           ST    Vascular
X20210128.RNA.Cov1                0.084226439 2.010806e-06 0.102461011
X20210128.RNA.Cov2                0.043057241 1.005924e-06 0.169533072
X20210128.RNA.Cov3                0.338976195 7.365366e-07 0.210604896
X20210128.RNA.Ctrl1               0.067247233 1.069072e-06 0.350462530
X20210128.RNA.Ctrl2               0.120580135 4.189616e-01 0.021133022
X20210128.RNA.Ctrl3               0.188919622 2.135598e-01 0.159996034
X20210413.RNA.seq.covid4.placenta 0.170492060 9.523773e-02 0.161865213
X20210413.RNA.seq.covid5.placenta 0.114260971 6.995568e-07 0.183139142
X20210413.RNA.seq.covid6.placenta 0.042868862 1.484226e-06 0.183065919
X20210413.RNA.seq.covid7.placenta 0.196240879 2.272424e-06 0.294446013
X20210413.RNA.seq.ctrl4.placenta  0.241235347 5.646776e-07 0.200068194
X20210413.RNA.seq.ctrl5.placenta  0.071789509 5.505970e-01 0.048570371
X20210413.RNA.seq.ctrl6.placenta  0.005887166 5.274084e-01 0.001347521

Sorry for my questions, Thanks for your reply.

xzhouaw avatar Aug 25 '21 04:08 xzhouaw

please see the vignette.pdf for details. please let me know if there are any questions.

On Wed, Aug 25, 2021 at 12:11 AM xzhouaw @.***> wrote:

Thanks! I used the following code to convert them to matrix and then the problem disappeared.

ref.dat <- data.matrix(read.csv("scRNA-counts-for.t-for.csv", header=TRUE, row.names=1, sep="\t")) X <- data.matrix(read.csv("placenta_genename-count.uniq.t.for.csv", header=TRUE, row.names=1, sep="\t"))

I am pretty new to R language, so after I got the result, I am not sure how to extract the cell proportion of each sample and the gene expression to a new file now. I used the followed code, but it reminded "Error: object 'res' not found".

fraction_1 <- res$first.gibbs.res$gibbs.theta write.csv(fraction_1, "initial_fraction.csv") fraction_2 <- res$first.gibbs.res$theta.merged write.csv(fraction_2, "summed_fraction.csv") expression_1 <- res$first.gibbs.res$Znkg write.csv(expression_1, "initial_expression.csv") expression_2 <- res$first.gibbs.res$Znkg.merged write.csv(expression_2, "summed_expression.csv")

By the way, this is the part of the result, is it the proportion of each cell types of different sample? Do I understand properly?

$res$first.gibbs.res$theta.merged Fibroblast ST Vascular X20210128.RNA.Cov1 0.084226439 2.010806e-06 0.102461011 X20210128.RNA.Cov2 0.043057241 1.005924e-06 0.169533072 X20210128.RNA.Cov3 0.338976195 7.365366e-07 0.210604896 X20210128.RNA.Ctrl1 0.067247233 1.069072e-06 0.350462530 X20210128.RNA.Ctrl2 0.120580135 4.189616e-01 0.021133022 X20210128.RNA.Ctrl3 0.188919622 2.135598e-01 0.159996034 X20210413.RNA.seq.covid4.placenta 0.170492060 9.523773e-02 0.161865213 X20210413.RNA.seq.covid5.placenta 0.114260971 6.995568e-07 0.183139142 X20210413.RNA.seq.covid6.placenta 0.042868862 1.484226e-06 0.183065919 X20210413.RNA.seq.covid7.placenta 0.196240879 2.272424e-06 0.294446013 X20210413.RNA.seq.ctrl4.placenta 0.241235347 5.646776e-07 0.200068194 X20210413.RNA.seq.ctrl5.placenta 0.071789509 5.505970e-01 0.048570371 X20210413.RNA.seq.ctrl6.placenta 0.005887166 5.274084e-01 0.001347521

Sorry for my questions, Thanks for your reply.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Danko-Lab/TED/issues/13#issuecomment-905167027, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB4NHS2CKPA223EV6T645DTT6RUNLANCNFSM5CTFCUYA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

tinyi avatar Aug 25 '21 15:08 tinyi