So I am basically trying calculate diffrences between datasets, but for some reason I receive the following error:"Error in expr1[overlap, ]: incorrect number of dimensions
It might be very simple but I can't seem to fix it.
I am reading 4 .RData files.They all contain the dataframe Expr
which has around 54000 rows and 10 columns with data. All files have the same column names but the rows names are not the same but for a big part they are so by using intersect I calculate the overlap but somehow this doesn't work as it should.
Example of the files:
file1:
GSM10 GSM11
1007_s_at 7.777639 8.582393
1053_at 9.029875 7.937305
117_at 7.026750 6.271279
121_at 7.800896 7.842556
1255_g_at 3.472406 3.486788
1294_at 6.332505 6.176560
file2:
GSM10 GSM11
1007_s_at 8.471424 9.499584
1053_at 9.047367 7.981026
1255_g_at 4.231098 4.226397
1294_at 7.482370 7.289183
Thanks in advance!!
Part of the code:
data <- list()
load("file1")
data$old_fRMA <- expr
load("file2")
data$old_PMfRMA <- expr
#runTimeInfo
load("file3")
data$new_PMfRMA <- expr
load("file3")
data$new_fRMA <- expr
##
compare.fRMA <-
function(expr1, expr2, no_duplicate_probeset = no_duplicate_probeset) {
overlap <- intersect(rownames(expr1), rownames(expr2))
expr1 <- expr1[overlap,]
expr2 <- expr2[overlap,]
datalength <- length(colnames(expr1))
difference <-
sapply(1:datalength, function(x)
abs(expr1[x] - expr2[x]))
difference.max <- sapply(difference, max)
difference.mean <- sapply(difference, mean)
out <- list()
#### All probesets ####
out$maxall <- max(difference.max)
out$meanall <- mean(difference.mean)
#################
expr1 <- expr1[no_duplicate_probeset,]
expr2 <- expr2[no_duplicate_probeset,]
difference <-
sapply(1:datalength, function(x)
abs(expr1[x] - expr2[x]))
difference.max <- sapply(difference, max)
difference.mean <- sapply(difference, mean)
#### TG probesets ####
out$maxTG <- max(difference.max)
out$meanTG <- mean(difference.mean)
return(out)
}
res <- list()
for (i in 1:4) {
res[i] <- list()
for (j in (i + 1):4) {
if (j>4) { break()
}
# print(paste(i,j ,sep=","))
res[i][j] <- compare.fRMA(data[i], data[j])
}
}