omnideconv / immunedeconv

A unified interface to immune deconvolution methods (CIBERSORT, EPIC, quanTIseq, TIMER, xCell, MCPcounter) and mouse deconvolution methods
https://omnideconv.org/immunedeconv/index.html
Other
451 stars 101 forks source link

Help with TIMER deconvolution method #49

Open masaver opened 4 years ago

masaver commented 4 years ago

Hi everyone,

I'm trying to run the TIMER deconvolution method on a set of lung normal & tumor RNAseq data, using the following line: res_timer = deconvolute( tpm , "timer" , indications = rep( "luad" , 116 ) )

However i get the following error:

>>> Running timer
## Enter batch mode

## Loading immune gene expression

[1] "Outlier genes: BANF1P4 FTL GAPDHP72 IGHG1 IGKC MALAT1 MIR6891 MT-ATP8 MT-CO3 RN7SK RN7SL1 RN7SL2 RN7SL3 RNU2-2P RPPH1 RPS26P5 SFTPC SNORD3A SPINK4"
## Removing the batch effect of C:\Users\SAVER~1.MAT\AppData\Local\Temp\RtmpiiOfyS\file3fb01d201503

Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...) : 
  'a' and 'b' must be finite

If i use the code to run TIMER, on two different datasets, the methods works fine.

Any idea of why this error is happening ?

Thanks in advance.

Best,

-Mathias

grst commented 4 years ago

Hi Mathias,

there must be something weird with your data. Did you make sure the data is not log-transformed?

To further narrow this down:

Best, Gregor

pl618 commented 4 years ago

I run TIMER on one sample.

> head(tpm_mat2)

          TPM
TSPAN6   24.51
TNMD      0.00
DPM1     22.63
SCYL3     5.47
C1orf112  2.68
FGR       3.16

> res_timer = deconvolute(tpm_mat2, "timer",indications=c("SKCM"))

>>> Running timer
## Enter batch mode

## Loading immune gene expression

[1] "Outlier genes: ALB HP MT-ATP8 MT-CO3 MT-ND3"
## Removing the batch effect of /tmp/RtmpYxDzKw/file2ab9f21c6d71ec

Found2batches
Note: one batch has only one sample, setting mean.only=TRUE
Adjusting for0covariate(s) or covariate level(s)
Standardizing Data across genes
Fitting L/S model and finding priors
Finding parametric adjustments
Adjusting the Data

Error in `colnames<-`(`*tmp*`, value = colnames(gene_expression_matrix)) :
  attempt to set 'colnames' on an object with less than two dimensions
grst commented 4 years ago

Hi @plsysu,

thanks for reporting! I suspect TIMER has a problem when running with only one sample :thinking:

To verify, could you please check:

Cheers, Gregor

pl618 commented 4 years ago

Hi @grst,

Yes, It's TIMER's problem.



> head(tpm_mat2)
           TPM  TPM2
TSPAN6   24.51 24.51
TNMD      0.00  0.00
DPM1     22.63 22.63
SCYL3     5.47  5.47
C1orf112  2.68  2.68
FGR       3.16  3.16
> res_timer = deconvolute(as.matrix(tpm_mat2), "timer",indications=c("SKCM","SKCM"))

>>> Running timer
## Enter batch mode

## Loading immune gene expression

[1] "Outlier genes: ALB HP MT-ATP8 MT-CO3 MT-ND3"
## Removing the batch effect of /tmp/RtmpbSz66r/file2c347b760d1e6

Found2batches
Adjusting for0covariate(s) or covariate level(s)
Standardizing Data across genes
Fitting L/S model and finding priors
Finding parametric adjustments
Error in while (change > conv) { : missing value where TRUE/FALSE needed
> tpm_mat2$TPM2 <- tpm_mat2$TPM2+1
> head(tpm_mat2)
           TPM  TPM2
TSPAN6   24.51 25.51
TNMD      0.00  1.00
DPM1     22.63 23.63
SCYL3     5.47  6.47
C1orf112  2.68  3.68
FGR       3.16  4.16

> res_timer = deconvolute(as.matrix(tpm_mat2), "timer",indications=c("SKCM","SKCM"))

>>> Running timer
## Enter batch mode

## Loading immune gene expression

[1] "Outlier genes: ALB HP MT-ATP8 MT-CO3 MT-ND3"
## Removing the batch effect of /tmp/RtmpbSz66r/file2c347b291646e4

Found2batches
Adjusting for0covariate(s) or covariate level(s)
Standardizing Data across genes
Fitting L/S model and finding priors
Finding parametric adjustments
Adjusting the Data

> res_timer
# A tibble: 6 x 3
  cell_type                 TPM   TPM2
  <chr>                   <dbl>  <dbl>
1 B cell                 0.105  0.107
2 T cell CD4+            0.115  0.117
3 T cell CD8+            0.207  0.209
4 Neutrophil             0.117  0.119
5 Macrophage             0.0473 0.0486
6 Myeloid dendritic cell 0.493  0.495
> set_cibersort_binary("/CIBERSORT/CIBERSORT_v1.03.R")
> set_cibersort_mat("/CIBERSORT/LM22.txt")
>
>
>
> res_cibersort = deconvolute(tpm_mat, "cibersort")

>>> Running cibersort
Error in (function (sig_matrix, mixture_file, perm = 0, QN = TRUE)  :
  unused arguments (absolute = FALSE, abs_method = "sig.score")
In addition: Warning message:
The `path` argument of `write_tsv()` is deprecated as of readr 1.4.0.
Please use the `file` argument instead.
This warning is displayed once every 8 hours.
Call `lifecycle::last_warnings()` to see where this warning was generated.
> res_cibersort = deconvolute(tpm_mat2, "cibersort")

>>> Running cibersort
Error in (function (sig_matrix, mixture_file, perm = 0, QN = TRUE)  :
  unused arguments (absolute = FALSE, abs_method = "sig.score")
> deconvolute(tpm_mat, "xcell")

>>> Running xcell
Error in if (dim(expr)[1] < 5000) { : argument is of length zero
> res_xcell = deconvolute(tpm_mat2, "xcell")

>>> Running xcell
Warning message:
In .local(expr, gset.idx.list, ...) :
  10789 genes with constant expression values throuhgout the samples.
> res_xcell
# A tibble: 39 x 3
   cell_type                          TPM  TPM2
   <chr>                            <dbl> <dbl>
 1 Myeloid dendritic cell activated     0     0
 2 B cell                               0     0
 3 T cell CD4+ memory                   0     0
 4 T cell CD4+ naive                    0     0
 5 T cell CD4+ (non-regulatory)         0     0
 6 T cell CD4+ central memory           0     0
 7 T cell CD4+ effector memory          0     0
 8 T cell CD8+ naive                    0     0
 9 T cell CD8+                          0     0
10 T cell CD8+ central memory           0     0
# … with 29 more rows
grst commented 4 years ago

Hi @plsysu,

thanks a lot for your detailed analysis. I'll try to fix that!

Regarding xcell being all-zero: xCell is really good at avoiding false-positive "background-predictions", while TIMER is really bad at it (see our paper, so it could actually be the case that there are none (or very few) immune cells present. Would you expect immune cells in your sample?

pl618 commented 4 years ago

Hi @grst,

This sample is obtained from a melanoma patient of a public data downloaded from SRA. It is expected to contain immune cells.

This paper is very helpful, it explained the problem I have met.


In particular, xCell uses the variability
among the samples for a linear transformation of the output score.
TIMER uses COMBAT (Johnson et al., 2007) to merge the input
samples with reference profiles. This is particularly problematic
with small datasets and hampers comparability and interpretability
of the score. Moreover, xCell does not detect any signal when ran
with few non-heterogeneous samples (Aran, 2018).

In particular, there is some warnings when running Xcell:

Warning message:
In .local(expr, gset.idx.list, ...) :
  10789genes with constant expression values throuhgout the samples.

It seems that all genes were filtered due to low variance accross samples by GSVA R package. Because there are only two samples, variance accross samples can not be estimated properly.

grst commented 4 years ago

Good point, I should have remembered hat one! I will add a warning message when running xCell with few samples.

zhangd236 commented 8 months ago

yi tuo da bian