所以我基本上尝试计算数据集之间的差异,但由于某种原因,我收到以下错误:"Error in expr1[overlap, ]: incorrect number of dimensions
这可能很简单,但我似乎无法修复它。
我正在阅读4个.RData文件。它们都包含数据框Expr
,其中包含大约54000行和10列数据。所有文件都具有相同的列名,但行名称不相同,但是对于很大一部分,它们是通过使用相交来计算重叠,但不知何故,这并没有按预期工作。
文件示例:
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
提前致谢!!
部分代码:
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])
}
}