Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in rmultinom #13

Open
xzhouaw opened this issue Aug 22, 2021 · 5 comments
Open

Error in rmultinom #13

xzhouaw opened this issue Aug 22, 2021 · 5 comments

Comments

@xzhouaw
Copy link

xzhouaw commented Aug 22, 2021

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~

@tinyi
Copy link
Collaborator

tinyi commented Aug 23, 2021 via email

@xzhouaw
Copy link
Author

xzhouaw commented Aug 23, 2021

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"

@tinyi
Copy link
Collaborator

tinyi commented Aug 24, 2021 via email

@xzhouaw
Copy link
Author

xzhouaw commented Aug 25, 2021

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.

@tinyi
Copy link
Collaborator

tinyi commented Aug 25, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants