Reputation: 9898
I am trying to run ComBat script on a dataset with 2 batches, but I am getting errors and I do not know how to inspect code since I am an R newbie.
I am running ComBat method in this way:
# Load sva
library(sva)
# Read expression values
dat = read.table('dataset.xls', header=TRUE, sep='\t')
# Read sample information file about batches
sif = read.delim('sif.tsv', header=TRUE, sep='\t')
# Call ComBat
ComBat(dat=dat,batch=sif$Batch, mod=NULL)
Anyway my output is:
Found 2 batches
Found 0 categorical covariate(s)
Found 54675 Missing Data Values
Standardizing Data across genes
Error in solve(t(des) %*% des) %*% t(des) %*% y1 :
requires numeric/complex matrix/vector arguments
Data format for dat is:
probe set <sample1> ... <sampleN>
<gene_name> <value1> ... <valueN>
...
Data format for sif is:
Array name Sample name Batch
<Array1> <Sample1> <Batch1>
...
Any hint is appreciated. I'll provide more info if needed.
Thanks
Upvotes: 1
Views: 2431
Reputation: 10553
It looks like when you're reading in the information it's not storing it in a format you expect.
From the error, ComBat
is expecting a matrix
with numeric
or complex
values. read.table
from memory will give you a data.frame
.
So try running:
dat <- as.matrix(dat)
ComBat(dat=dat,batch=sif$Batch, mod=NULL)
Upvotes: 1
Reputation: 9898
I have figured out how to do it, adding:
# Remove NA from end of lines
l_dat = length(dat)
dat[l_dat] <- NULL
# Remove probe set from beginning of lines
dat[1] <- NULL
just before the ComBat call. This because last column contains NA
values (next warning goes away:
Found 54675 Missing Data Values
), and first column contains probe set (non numeric values) that raise next error:
Error in solve(t(des) %*% des) %*% t(des) %*% y1 :
requires numeric/complex matrix/vector arguments
Upvotes: 0