Question: How to perform batch correction when we have only single condition?
gravatar for svp
7 months ago by
svp420 wrote:

I have only single condition "Cancer" and where processed as three batches.

SampleID    Condition   Batch
Sample1      Cancer      A1
Sample2      Cancer      A1
Sample3      Cancer      A1
Sample4      Cancer      A1
Sample5      Cancer      A1
Sample6      Cancer      A1
Sample7      Cancer      A1
Sample8      Cancer      A2
Sample9      Cancer      A2
Sample10     Cancer      A2
Sample11     Cancer      A2
Sample12     Cancer      A2
Sample13     Cancer      A2
Sample14     Cancer      A2
Sample15     Cancer      A3
Sample16     Cancer      A3
Sample17     Cancer      A3
Sample18     Cancer      A3
Sample19     Cancer      A3
Sample20     Cancer      A3
Sample21     Cancer      A3

followed following method to normalize and batch correction

#Read the count table data
cts <- read.table("raw_read_count.txt", header=TRUE, row.names=1)

#Sample information and barch details
coldata <- read.table("sample_info.txt", header=TRUE, row.names=1)

#Create a DESeq2 object named dds from the gene read count and sample information
dds <- DESeqDataSetFromMatrix(countData = cts,
                              colData = coldata,
                              design = ~ 1)

#assign the batch column
dds$batch <- factor(dds$Batch)

#estimate the library size correction and save the normalized counts matrix
dds <- estimateSizeFactors(dds)
norm.cts <- counts(dds, normalized=TRUE)

#perform regularized log transformation (blind false)
rld_f <- rlog(dds, blind=FALSE)

Next step is to do a batch correction. I followed the method given here as follows:

mm <- model.matrix(~ Condition, colData(dds))
mm0 <- model.matrix(~ 1, colData(dds))
norm.cts <- norm.cts[rowSums(norm.cts) > 0,]
fit <- svaseq(norm.cts, mod=mm, mod0=mm0,

where it ask for mm and mm0; and mm does not work for me as I have only single condition. How can I go ahead with this? What changes has to made in the above code ?

combat deseq2 sva batcheffects • 340 views
ADD COMMENTlink modified 7 months ago • written 7 months ago by svp420
gravatar for svp
7 months ago by
svp420 wrote:

I am updating the answer. If anyone stuck on the operation can follow

#get the matrix of regularized log count
rlog_count = assay(rld_f)

#Create model
cb.corr.model <- model.matrix(~1, data = coldata)

#Batch correction using combat
cb.corr.counts = ComBat(dat=rlog_count,
ADD COMMENTlink written 7 months ago by svp420
gravatar for i.sudbery
7 months ago by
Sheffield, UK
i.sudbery11k wrote:

SVA is used to find (not necessarily remove) unknown sources of variation. Here your source of error is known - you know which batch each sample came from.

I recommend using removeBatchEffects from limma instead.

ADD COMMENTlink written 7 months ago by i.sudbery11k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2331 users visited in the last hour