Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to use combat in R??

    I'm trying to use combat to correct for batch effect in our dataset. The sample csv files contains genes in rows, and samples in columns, and expression values are from different microarray. We have in total 6 batches, and the sif file contains 3 columns : arrays, samples, batch (as per the manual). R generates an error message when running combat.. I'm not sure what to do from here. What am I doing wrong??


    Library(sva)
    dat = read.csv("Combat_matrix_input.csv");
    sif = read.csv("sif.csv");

    modcombat = model.matrix(~1, data=dat)

    newdata = ComBat(dat=dat, batch=sif$Batch, par.prior = TRUE, mod = modcombat)
    Found 6 batches
    Error in cbind(batchmod, mod) :
    number of rows of matrices must match (see arg 2)

  • #2
    I think the problem is that your modcombat matrix doesn't have the right dimensions. When you run

    Code:
    modcombat = model.matrix(~1, data=dat)
    you'll get an n by 1 matrix with each entry equal to 1, where n is the number of records or lines in the csv file. What you really want is an m by 1 matrix full of 1's, where m is the number of fields or columns of the csv file, assuming that you don't have any covariates in your data. If you do have covariates, just make a vector that describes the covariate and pass that in to the model.matrix function. Like this

    Code:
    modcombat = model.matrix(~ covariates)

    Comment

    Latest Articles

    Collapse

    • seqadmin
      Recent Developments in Metagenomics
      by seqadmin





      Metagenomics has improved the way researchers study microorganisms across diverse environments. Historically, studying microorganisms relied on culturing them in the lab, a method that limits the investigation of many species since most are unculturable1. Metagenomics overcomes these issues by allowing the study of microorganisms regardless of their ability to be cultured or the environments they inhabit. Over time, the field has evolved, especially with the advent...
      09-23-2024, 06:35 AM
    • seqadmin
      Understanding Genetic Influence on Infectious Disease
      by seqadmin




      During the COVID-19 pandemic, scientists observed that while some individuals experienced severe illness when infected with SARS-CoV-2, others were barely affected. These disparities left researchers and clinicians wondering what causes the wide variations in response to viral infections and what role genetics plays.

      Jean-Laurent Casanova, M.D., Ph.D., Professor at Rockefeller University, is a leading expert in this crossover between genetics and infectious...
      09-09-2024, 10:59 AM

    ad_right_rmr

    Collapse

    News

    Collapse

    Topics Statistics Last Post
    Started by seqadmin, 10-02-2024, 04:51 AM
    0 responses
    13 views
    0 likes
    Last Post seqadmin  
    Started by seqadmin, 10-01-2024, 07:10 AM
    0 responses
    21 views
    0 likes
    Last Post seqadmin  
    Started by seqadmin, 09-30-2024, 08:33 AM
    0 responses
    25 views
    0 likes
    Last Post seqadmin  
    Started by seqadmin, 09-26-2024, 12:57 PM
    0 responses
    18 views
    0 likes
    Last Post seqadmin  
    Working...
    X