dgrun / StemID

Algorithm for the inference of cell types and lineage trees from single-cell RNA-seq data.
40 stars 19 forks source link

Bypassing filterdata function #6

Closed joelmarkus closed 2 years ago

joelmarkus commented 2 years ago

I can't run Ltree if I don't run the function filterdata. Is there any way to sort this issue? All I wish to do is calculate the cell entropy. Thanks.

dgrun commented 2 years ago

Just run filterdata with relaxed parameters (mintotal=1, minexp=0). This way you don't filter out any cells.

joelmarkus commented 2 years ago

Hey, thanks for the response but when I use these parameters (or similar low values), I get the following error;

Error in if (coef(fit)[3] >= 0 | mm >= mthr) { : missing value where TRUE/FALSE needed

How do I solve this?

dgrun commented 2 years ago

Hard to say. Do you have sample code and data to reproduce this?

joelmarkus commented 2 years ago

I wish to calculate the entropy for the given set of genes (attached).

#read countmatrix here entropy_cell <- as.data.frame(compentropy(Ltree(filterdata(SCseq(countmatrix), mintotal = 1, minexpr = 0)))@entropy)

filterdata gives me the "missing values" error.

Again, thanks for your help.

countmatrix.txt

dgrun commented 2 years ago

The max colSum in your data is 27. Are these scRNA-seq data? This would be quite unusual. The fit of the background model doesn't work, because there are only few genes wit few non-zero counts.

If you'd just like to compute the entropy, you can use this code:

probs <- t(t(countmatrix)/colSums(countmatrix)) entropy <- -apply(probs * log(probs + 1e-10)/log(nrow(countmatrix)), 2, sum)

joelmarkus commented 2 years ago

It is scRNA-seq data-- I subsetted it to calculate the entropy of only a set of genes.

I shall only use the formula instead. Thank you so much.