statOmics/tradeSeq

associationTest is renaming Lineages instead of reusing them

ccasar opened this issue · 0 comments

Hi,

I have a dataset with multiple Lineages from Slingshot and decided to run tradeSeq only on Lineage1 and 4. fitGAM correctly uses these lineage names:

> colnames(after_tradeseq$crv)
[1] "pseudotime.Lineage1"  "pseudotime.Lineage4"  "cellWeights.Lineage1" "cellWeights.Lineage4"

But when I run associationTest on these results using the lineages = TRUE option, the lineages get renamed to lineage1 and lineage2:

> colnames(rowData(after_tradeseq)$assocRes)
 [1] "waldStat"                                   "df"                                         "pvalue"                                    
 [4] "waldStat_lineage1"       "df_lineage1"             "pvalue_lineage1"        
[7] "meanLogFC"  

Note: These result originally include the results for different conditions, so to reduce clutter I manually adapted the output.

Overall it's probably not a big deal, but it's something I would not expect and is not documented in the function's help pages.

Here is some example code based on your test data:

set.seed(8)
data(crv, package="tradeSeq")
data(countMatrix, package="tradeSeq")

lineages_use <- "curve2"

lineage_cellweights <- slingCurveWeights(SlingshotDataSet(crv))[,lineages_use,drop=FALSE]
lineage_cellweights <- lineage_cellweights[rowSums(lineage_cellweights) != 0,,drop=FALSE]

lineage_pseudotimes <- slingPseudotime(SlingshotDataSet(crv), na = FALSE)[,lineages_use,drop=FALSE]
lineage_pseudotimes <- lineage_pseudotimes[rownames(lineage_cellweights),
                                           colnames(lineage_pseudotimes) %in% colnames(lineage_cellweights),
                                           drop=FALSE]
lineage_cells <- countMatrix[,colnames(countMatrix) %in% rownames(lineage_pseudotimes)]


sce <- fitGAM(counts = lineage_cells,
                 genes = rownames(lineage_cells),
                 pseudotime = lineage_pseudotimes,
                 cellWeights = lineage_cellweights,
                 nknots = 5)

assocRes <- associationTest(sce,lineages = TRUE)

> colnames(assocRes)
[1] "waldStat"   "df"         "pvalue"     "waldStat_1" "df_1"       "pvalue_1"   "meanLogFC"

# predictSmooth is doing this as well
smooth_res <- predictSmooth(sce, gene = 1:10)

> table(smooth_res$lineage)
   1 
1000 

Here curve2 gets renamed to 1 (not 100% sure why curve get's dropped or the word lineage is missing)

Edit: the same is true for predictSmooth, I've added it to the example above.
Edit 2: conditionTest does the same if lineages = TRUE is set