error in limma , contrast.matrix Number of rows of contrast matrix must match number of coefficients in fit
1
0
Entering edit mode
zzrammal • 0
@9ae4560e
Last seen 4 days ago
France

hello all, i am doing a differential gene expression analysis using limma, i have 3 conditions S0,S1, and S3. I am creating the contrasts and doing the fit function but its giving the error ( Number of rows of contrast matrix must match number of coefficients in fit)

> contrast.matrix <- makeContrasts(
+   S1_vs_S0 = S1 - S0,
+   S3_vs_S0 = S3 - S0,
+   S1_vs_S3 = S1 - S3,
+   levels = design
+ )
> 
> # Fit contrasts
> fit2 <- limma::contrasts.fit(fit, contrast.matrix)
Error in limma::contrasts.fit(fit, contrast.matrix) : 
  Number of rows of contrast matrix must match number of coefficients in fit

the number of row in contrast matrix is 3L  and nb of coefficient in fit 24670L

> sessionInfo()
R version 4.1.1 (2021-08-10)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: Ubuntu 20.04.6 LTS

Matrix products: default
BLAS/LAPACK: /shared/ifbstor1/software/miniconda/envs/r-4.1.1/lib/libopenblasp-r0.3.18.so

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

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

other attached packages:
 [1] rtracklayer_1.54.0                       DiffBind_3.4.11                          BiocParallel_1.28.3                     
 [4] BiocManager_1.30.23                      openxlsx_4.2.5.2                         TxDb.Hsapiens.UCSC.hg38.knownGene_3.14.0
 [7] GenomicFeatures_1.46.5                   org.Hs.eg.db_3.14.0                      AnnotationDbi_1.56.1                    
[10] ChIPpeakAnno_3.28.0                      ChIPseeker_1.30.3                        magrittr_2.0.3                          
[13] lubridate_1.9.3                          forcats_1.0.0                            stringr_1.5.1                           
[16] dplyr_1.1.4                              purrr_1.0.2                              readr_2.1.5                             
[19] tidyr_1.3.1                              tibble_3.2.1                             tidyverse_2.0.0                         
[22] DESeq2_1.34.0                            SummarizedExperiment_1.24.0              MatrixGenerics_1.6.0                    
[25] matrixStats_0.62.0                       GenomicRanges_1.46.1                     GenomeInfoDb_1.30.1                     
[28] IRanges_2.28.0                           S4Vectors_0.32.4                         Biobase_2.54.0                          
[31] BiocGenerics_0.40.0                      limma_3.50.3                             ggplot2_3.5.1                           

loaded via a namespace (and not attached):
  [1] utf8_1.2.2                              tidyselect_1.2.1                        RSQLite_2.2.8                          
  [4] htmlwidgets_1.5.4                       grid_4.1.1                              scatterpie_0.1.7                       
  [7] munsell_0.5.0                           systemPipeR_2.0.4                       withr_2.5.0                            
 [10] colorspace_2.0-3                        GOSemSim_2.20.0                         filelock_1.0.2                         
 [13] rstudioapi_0.16.0                       DOSE_3.20.1                             labeling_0.4.2                         
 [16] bbmle_1.0.24                            GenomeInfoDbData_1.2.7                  mixsqp_0.3-43                          
 [19] hwriter_1.3.2                           polyclip_1.10-0                         bit64_4.0.5                            
 [22] farver_2.1.1                            coda_0.19-4                             vctrs_0.6.5                            
 [25] treeio_1.18.1                           generics_0.1.3                          lambda.r_1.2.4                         
 [28] timechange_0.3.0                        BiocFileCache_2.2.0                     regioneR_1.26.0                        
 [31] R6_2.5.1                                apeglm_1.16.0                           graphlayouts_0.8.0                     
 [34] invgamma_1.1                            locfit_1.5-9.4                          AnnotationFilter_1.18.0                
 [37] bitops_1.0-7                            cachem_1.0.6                            fgsea_1.20.0                           
 [40] gridGraphics_0.5-1                      DelayedArray_0.20.0                     BiocIO_1.4.0                           
 [43] scales_1.3.0                            ggraph_2.0.5                            enrichplot_1.14.1                      
 [46] gtable_0.3.1                            ensembldb_2.18.4                        tidygraph_1.2.0                        
 [49] rlang_1.1.3                             genefilter_1.76.0                       splines_4.1.1                          
 [52] lazyeval_0.2.2                          yaml_2.3.6                              reshape2_1.4.4                         
 [55] qvalue_2.26.0                           RBGL_1.70.0                             tools_4.1.1                            
 [58] ggplotify_0.1.0                         gplots_3.1.3.1                          RColorBrewer_1.1-3                     
 [61] Rcpp_1.0.9                              plyr_1.8.7                              progress_1.2.2                         
 [64] zlibbioc_1.40.0                         RCurl_1.98-1.9                          prettyunits_1.1.1                      
 [67] viridis_0.6.2                           ashr_2.2-47                             ggrepel_0.9.1                          
 [70] data.table_1.14.2                       futile.options_1.0.1                    DO.db_2.9                              
 [73] truncnorm_1.0-8                         mvtnorm_1.1-3                           SQUAREM_2021.1                         
 [76] amap_0.8-19                             ProtGenerics_1.26.0                     hms_1.1.3                              
 [79] patchwork_1.1.1                         xtable_1.8-4                            XML_3.99-0.9                           
 [82] VennDiagram_1.7.0                       emdbook_1.3.12                          jpeg_0.1-9                             
 [85] gridExtra_2.3                           compiler_4.1.1                          biomaRt_2.50.0                         
 [88] bdsmatrix_1.3-7                         KernSmooth_2.23-20                      crayon_1.5.2                           
 [91] shadowtext_0.0.9                        htmltools_0.5.2                         ggfun_0.0.4                            
 [94] tzdb_0.2.0                              geneplotter_1.72.0                      aplot_0.1.1                            
 [97] DBI_1.2.2                               tweenr_1.0.2                            formatR_1.11                           
[100] dbplyr_2.5.0                            MASS_7.3-54                             rappdirs_0.3.3                         
[103] boot_1.3-28                             ShortRead_1.52.0                        Matrix_1.3-4                           
[106] cli_3.6.2                               parallel_4.1.1                          igraph_1.3.1                           
[109] pkgconfig_2.0.3                         TxDb.Hsapiens.UCSC.hg19.knownGene_3.2.2 GenomicAlignments_1.30.0               
[112] numDeriv_2016.8-1.1                     xml2_1.3.3                              InteractionSet_1.22.0                  
[115] ggtree_3.2.1                            annotate_1.72.0                         multtest_2.50.0                        
[118] XVector_0.34.0                          yulab.utils_0.0.4                       digest_0.6.30                          
[121] graph_1.72.0                            Biostrings_2.62.0                       fastmatch_1.1-3                        
[124] tidytree_0.3.6                          edgeR_3.36.0                            restfulr_0.0.13                        
[127] GreyListChIP_1.26.0                     curl_5.2.1                              Rsamtools_2.10.0                       
[130] gtools_3.9.3                            rjson_0.2.20                            lifecycle_1.0.3                        
[133] nlme_3.1-153                            jsonlite_1.8.8                          futile.logger_1.4.3                    
[136] viridisLite_0.4.1                       BSgenome_1.62.0                         fansi_1.0.3                            
[139] pillar_1.9.0                            lattice_0.20-45                         KEGGREST_1.34.0                        
[142] fastmap_1.1.0                           httr_1.4.7                              plotrix_3.8-2                          
[145] survival_3.2-13                         GO.db_3.14.0                            glue_1.6.2                             
[148] zip_2.2.0                               png_0.1-7                               bit_4.0.4                              
[151] ggforce_0.3.3                           stringi_1.7.8                           blob_1.2.2                             
[154] latticeExtra_0.6-29                     caTools_1.18.2                          memoise_2.0.1                          
[157] irlba_2.3.5.1                           ape_5.5                                
>

I dont really understand the problem becaus ethe concept of coeficient in fit is not so clear to me.

Thank u in advance.

limma • 286 views
ADD COMMENT
2
Entering edit mode
@james-w-macdonald-5106
Last seen 4 minutes ago
United States

I doubt you have that many contrasts. I think that is probably the number of rows. What does dim(fit) return (and head(fit$coef))?

0
Entering edit mode

thank you for your response. The problem is resolved. When i did a fit for the linear model i put NULL for the design fit <- lmFit(count_data, design=NULL) and thats what was causing the problem.

ADD REPLY

Login before adding your answer.

Traffic: 737 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6