statOmics/tradeSeq

startVsEndTest yields results for non existing pseudotimeValues

sam-israel opened this issue · 1 comments

I have run fitGAM on slingshot results, within one lineage, with 3 knots.

Note: this specific choice of knots is due to the fact that there are precisely 3 cell states in which I am interested - in the beginning, end, and in the middle (according to the slingshot DPT).

The DPT in the slingshot trajectory ranges from 0 to 0.1.
However, running startVsEndTest(pseudotimeValues=c(0.1,0.3)) does yield results.

Col1slingRes_filt_GAM@metadata$tradeSeq$knots

       0%       50%      100% 
0.0000000 0.0608644 0.1024949 

(res <- Col1slingRes_filt_GAM %>% startVsEndTest(pseudotimeValues = c(0.1, 0.3))%>% mutate(padj = p.adjust(pvalue, method="BH")) %>%  filter(padj<0.05))

waldStat | df | pvalue| logFClineage1 |  
ENSG00000176022 | 21.121796 | 1 | 4.309978e-06 | 21.4182296 |  
ENSG00000175756 | 12.047226 | 1 | 5.186952e-04 | -8.2553983 |  
ENSG00000242485| 15.522301 | 1 | 8.153764e-05 | -8.8633407 |  
ENSG00000160075 | 12.472358 | 1 | 4.130184e-04 | 8.4384998 |
...

res %>% nrow()
[1] 2611
...



Session info

R version 4.3.0 (2023-04-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.6 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=en_IL.UTF-8       LC_NUMERIC=C               LC_TIME=en_IL.UTF-8       
 [4] LC_COLLATE=en_IL.UTF-8     LC_MONETARY=en_IL.UTF-8    LC_MESSAGES=en_IL.UTF-8   
 [7] LC_PAPER=en_IL.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_IL.UTF-8 LC_IDENTIFICATION=C       

time zone: Asia/Jerusalem
tzcode source: system (glibc)

attached base packages:
[1] grid      stats4    stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] sva_3.48.0                  BiocParallel_1.34.2         genefilter_1.82.1          
 [4] mgcv_1.8-42                 nlme_3.1-162                RColorBrewer_1.1-3         
 [7] pheatmap_1.0.12             ggrepel_0.9.3               VennDiagram_1.7.3          
[10] futile.logger_1.4.3         traviz_1.6.0                enrichR_3.2                
[13] tradeSeq_1.13.01            slingshot_2.8.0             TrajectoryUtils_1.8.0      
[16] SingleCellExperiment_1.22.0 SummarizedExperiment_1.30.2 Biobase_2.60.0             
[19] GenomicRanges_1.52.0        GenomeInfoDb_1.36.0         IRanges_2.34.0             
[22] S4Vectors_0.38.1            BiocGenerics_0.46.0         MatrixGenerics_1.12.2      
[25] matrixStats_1.0.0           princurve_2.1.6             glue_1.6.2                 
[28] destiny_3.14.0              ggplot2_3.4.2               dplyr_1.1.2                
[31] SeuratObject_4.1.3          Seurat_4.3.0               

loaded via a namespace (and not attached):
  [1] spatstat.sparse_3.0-1   bitops_1.0-7            httr_1.4.6              tools_4.3.0            
  [5] sctransform_0.3.5       utf8_1.2.3              R6_2.5.1                lazyeval_0.2.2         
  [9] uwot_0.1.14             withr_2.5.0             sp_1.6-1                gridExtra_2.3          
 [13] progressr_0.13.0        cli_3.6.1               formatR_1.14            spatstat.explore_3.2-1 
 [17] sass_0.4.6              robustbase_0.99-0       spatstat.data_3.0-1     proxy_0.4-27           
 [21] ggridges_0.5.4          pbapply_1.7-0           parallelly_1.36.0       WriteXLS_6.4.0         
 [25] limma_3.56.2            TTR_0.24.3              rstudioapi_0.14         RSQLite_2.3.1          
 [29] generics_0.1.3          ica_1.0-3               spatstat.random_3.1-5   car_3.1-2              
 [33] Matrix_1.5-4.1          fansi_1.0.4             abind_1.4-5             lifecycle_1.0.3        
 [37] scatterplot3d_0.3-44    yaml_2.3.7              edgeR_3.42.4            carData_3.0-5          
 [41] Rtsne_0.16              blob_1.2.4              promises_1.2.0.1        crayon_1.5.2           
 [45] miniUI_0.1.1.1          lattice_0.21-8          cowplot_1.1.1           annotate_1.78.0        
 [49] KEGGREST_1.40.0         pillar_1.9.0            knitr_1.43              rjson_0.2.21           
 [53] boot_1.3-28.1           future.apply_1.11.0     codetools_0.2-19        leiden_0.4.3           
 [57] pcaMethods_1.92.0       data.table_1.14.8       vcd_1.4-11              vctrs_0.6.3            
 [61] png_0.1-8               gtable_0.3.3            cachem_1.0.8            xfun_0.39              
 [65] S4Arrays_1.0.4          mime_0.12               RcppEigen_0.3.3.9.3     rsconnect_0.8.29       
 [69] survival_3.5-5          rgl_1.2.1               ellipsis_0.3.2          fitdistrplus_1.1-11    
 [73] ROCR_1.0-11             xts_0.13.1              bit64_4.0.5             RcppAnnoy_0.0.20       
 [77] bslib_0.5.0             irlba_2.3.5.1           KernSmooth_2.23-21      colorspace_2.1-0       
 [81] DBI_1.1.3               nnet_7.3-19             tidyselect_1.2.0        smoother_1.1           
 [85] bit_4.0.5               compiler_4.3.0          curl_5.0.1              DelayedArray_0.26.3    
 [89] plotly_4.10.2           scales_1.2.1            DEoptimR_1.0-14         lmtest_0.9-40          
 [93] hexbin_1.28.3           stringr_1.5.0           digest_0.6.31           goftest_1.2-3          
 [97] spatstat.utils_3.0-3    rmarkdown_2.22          XVector_0.40.0          htmltools_0.5.5        
[101] pkgconfig_2.0.3         base64enc_0.1-3         fastmap_1.1.1           rlang_1.1.1            
[105] htmlwidgets_1.6.2       ggthemes_4.2.4          shiny_1.7.4             jquerylib_0.1.4        
[109] zoo_1.8-12              jsonlite_1.8.5          RCurl_1.98-1.12         magrittr_2.0.3         
[113] GenomeInfoDbData_1.2.10 patchwork_1.1.2         munsell_0.5.0           Rcpp_1.0.10            
[117] viridis_0.6.3           reticulate_1.30         stringi_1.7.12          zlibbioc_1.46.0        
[121] MASS_7.3-60             plyr_1.8.8              parallel_4.3.0          listenv_0.9.0          
[125] deldir_1.0-9            Biostrings_2.68.1       splines_4.3.0           tensor_1.5             
[129] locfit_1.5-9.8          igraph_1.5.0            ranger_0.15.1           spatstat.geom_3.2-1    
[133] RcppHNSW_0.4.1          reshape2_1.4.4          futile.options_1.0.1    XML_3.99-0.14          
[137] evaluate_0.21           lambda.r_1.2.4          laeken_0.5.2            httpuv_1.6.11          
[141] VIM_6.2.2               RANN_2.6.1              tidyr_1.3.0             purrr_1.0.1            
[145] polyclip_1.10-4         future_1.32.0           scattermore_1.2         xtable_1.8-4           
[149] e1071_1.7-13            RSpectra_0.16-1         later_1.3.1             viridisLite_0.4.2      
[153] class_7.3-22            tibble_3.2.1            memoise_2.0.1           AnnotationDbi_1.62.1   
[157] cluster_2.1.4           ggplot.multistats_1.0.0 globals_0.16.2         

Hi @sam-israel

Thank you for posting. This indeed does not error, and the fitted values you will get are based on interpolation of the basis functions. It is not something we recommend doing indeed and therefore the function should now return an error as soon as you interpolate to pseudotime values higher than the observed maximum pseudotime.