Skip to content

Error occurs when plotting PLS feature importance #67

@Chuan-Jiang

Description

@Chuan-Jiang

First of all, thanks for your excellent work. I have learned a lot of skills here.

I can reproduce all results with demo datasets. However, When I repeat it with my own data, some error occured as following:

test.zip

library(structToolbox)
load("test.Rdata")

mD <- DatasetExperiment(name = "mD", 
                        data = mconc, 
                        sample_meta = mmeta,
                        variable_meta = data.frame(variable = colnames(mconc),row.names =  colnames(mconc) ) ,
                        description = "The test"
                       )
mD$sample_meta$FN <- as.factor(mD$sample_meta$FN)


P = PLSDA(number_components = 2, factor_name= "FN" )

# apply the model
P = model_apply(P,mD)

C = pls_scores_plot(components=c(1,2),factor_name = "FN" )
chart_plot(C,P)



# prepare chart
C = pls_vip_plot(ycol = 'HE')
g1 = chart_plot(C,P)

the Erroe message like this:

Error in `$<-.data.frame`(`*tmp*`, "feature", value = c("pos.M68T423", :
replacement has 1000 rows, data has 0
6.
stop(sprintf(ngettext(N, "replacement has %d row, data has %d",
"replacement has %d rows, data has %d"), N, nrows), domain = NA)
5.
`$<-.data.frame`(`*tmp*`, "feature", value = c("pos.M68T423",
"pos.M69T424", "pos.M70T363", "pos.M70T442", "pos.M70T535", "pos.M70T258",
"pos.M71T363", "pos.M72T349", "pos.M73T351", "pos.M74T449", "pos.M74T415",
"pos.M74T57", "pos.M74T129", "pos.M74T403", "pos.M74T602", "pos.M75T415", ...
4.
`$<-`(`*tmp*`, "feature", value = c("pos.M68T423", "pos.M69T424",
"pos.M70T363", "pos.M70T442", "pos.M70T535", "pos.M70T258", "pos.M71T363",
"pos.M72T349", "pos.M73T351", "pos.M74T449", "pos.M74T415", "pos.M74T57",
"pos.M74T129", "pos.M74T403", "pos.M74T602", "pos.M75T415", "pos.M76T415", ...
3.
.local(obj, dobj, ...)
2.
chart_plot(C, P)
1.
chart_plot(C, P)

my R evironment :

R version 4.3.2 (2023-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.1 LTS

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

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

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

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

other attached packages:
 [1] remotes_2.4.2.1      xlsx_0.6.5           pmp_1.14.0           BiocFileCache_2.10.1 dbplyr_2.4.0         cowplot_1.1.1        structToolbox_1.14.0 struct_1.14.0        lubridate_1.9.3     
[10] forcats_1.0.0        stringr_1.5.1        dplyr_1.1.4          purrr_1.0.2          readr_2.1.4          tidyr_1.3.0          tibble_3.2.1         ggplot2_3.4.4        tidyverse_2.0.0     
[19] omu_1.1.1           

loaded via a namespace (and not attached):
  [1] rstudioapi_0.15.0           magrittr_2.0.3              farver_2.1.1                zlibbioc_1.48.0             vctrs_0.6.4                 memoise_2.0.1              
  [7] RCurl_1.98-1.13             rstatix_0.7.2               S4Arrays_1.2.0              itertools_0.1-3             missForest_1.5              curl_5.1.0                 
 [13] broom_1.0.5                 SparseArray_1.2.2           pROC_1.18.5                 caret_6.0-94                FSA_0.9.5                   parallelly_1.36.0          
 [19] desc_1.4.2                  plyr_1.8.9                  impute_1.76.0               cachem_1.0.8                lifecycle_1.0.4             iterators_1.0.14           
 [25] pkgconfig_2.0.3             Matrix_1.6-3                R6_2.5.1                    fastmap_1.1.1               GenomeInfoDbData_1.2.11     MatrixGenerics_1.14.0      
 [31] future_1.33.0               digest_0.6.33               pcaMethods_1.94.0           colorspace_2.1-0            ps_1.7.5                    S4Vectors_0.40.1           
 [37] rprojroot_2.0.4             GenomicRanges_1.54.1        RSQLite_2.3.3               filelock_1.0.2              labeling_0.4.3              randomForest_4.7-1.1       
 [43] fansi_1.0.5                 timechange_0.2.0            httr_1.4.7                  abind_1.4-5                 compiler_4.3.2              rngtools_1.5.2             
 [49] bit64_4.0.5                 withr_2.5.2                 backports_1.4.1             carData_3.0-5               DBI_1.1.3                   pkgbuild_1.4.2             
 [55] MASS_7.3-60                 lava_1.7.3                  DelayedArray_0.28.0         ModelMetrics_1.2.2.2        tools_4.3.2                 future.apply_1.11.0        
 [61] nnet_7.3-19                 glue_1.6.2                  callr_3.7.3                 nlme_3.1-163                grid_4.3.2                  reshape2_1.4.4             
 [67] generics_0.1.3              recipes_1.0.8               gtable_0.3.4                tzdb_0.4.0                  class_7.3-22                data.table_1.14.8          
 [73] hms_1.1.3                   sp_2.1-1                    car_3.1-2                   utf8_1.2.4                  XVector_0.42.0              BiocGenerics_0.48.1        
 [79] foreach_1.5.2               pillar_1.9.0                rJava_1.0-6                 splines_4.3.2               lattice_0.22-5              survival_3.5-7             
 [85] bit_4.0.5                   tidyselect_1.2.0            knitr_1.45                  gridExtra_2.3               IRanges_2.36.0              SummarizedExperiment_1.32.0
 [91] stats4_4.3.2                xfun_0.41                   pls_2.8-3                   Biobase_2.62.0              hardhat_1.3.0               timeDate_4022.108          
 [97] matrixStats_1.1.0           stringi_1.8.1               xlsxjars_0.6.1              codetools_0.2-19            BiocManager_1.30.22         cli_3.6.1                  
[103] ontologyIndex_2.11          rpart_4.1.21                processx_3.8.2              munsell_0.5.0               Rcpp_1.0.11                 GenomeInfoDb_1.38.1        
[109] globals_0.16.2              parallel_4.3.2              ggfortify_0.4.16            gower_1.0.1                 blob_1.2.4                  prettyunits_1.2.0          
[115] doRNG_1.8.6                 bitops_1.0-7                listenv_0.9.0               ggthemes_4.2.4              viridisLite_0.4.2           ipred_0.9-14               
[121] scales_1.2.1                prodlim_2023.08.28          crayon_1.5.2                rlang_1.1.2                

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions