Header Leaderboard Ad

Collapse

How to use combat in R??

Collapse

Announcement

Collapse

SEQanswers June Challenge Has Begun!

The competition has begun! We're giving away a $50 Amazon gift card to the member who answers the most questions on our site during the month. We want to encourage our community members to share their knowledge and help each other out by answering questions related to sequencing technologies, genomics, and bioinformatics. The competition is open to all members of the site, and the winner will be announced at the beginning of July. Best of luck!

For a list of the official rules, visit (https://www.seqanswers.com/forum/sit...wledge-and-win)
See more
See less
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

    ad_right_rmr

    Collapse

    News

    Collapse

    Topics Statistics Last Post
    Started by seqadmin, Yesterday, 10:20 AM
    0 responses
    9 views
    0 likes
    Last Post seqadmin  
    Started by seqadmin, 06-07-2023, 07:14 AM
    0 responses
    13 views
    0 likes
    Last Post seqadmin  
    Started by seqadmin, 06-06-2023, 01:08 PM
    0 responses
    13 views
    0 likes
    Last Post seqadmin  
    Started by seqadmin, 06-01-2023, 08:56 PM
    0 responses
    166 views
    0 likes
    Last Post seqadmin  
    Working...
    X