I have this matrix of expression data
> head(data[,1:6])
Symbol cl1 cl1.1 cl1.2 cl1.3 cl1.4
1 ACTB 14.07922 14.25211 13.547206 14.046814 15.33551
2 ATP5F1 10.43386 10.34219 9.671036 9.862641 10.39786
3 DDX5 13.99250 13.29734 13.706894 13.084000 13.73379
4 EEF1G 14.35303 14.26112 13.523434 13.327333 13.97747
5 GAPDH 16.07695 15.61435 15.454911 15.233670 15.90100
6 NCL 14.35149 13.32919 13.051861 12.704973 13.55680
>
I have 24 samples as cl1 and 30 samples as cl2
I want to do a t.tset, I have this function but I am not sure Why I am getting error by
volcan <- function(data, cl1, cl2) {
tt <- t(apply(data[, -1], 1, function(d){z <- t.test(d[cl1], d[cl2]); c(z$estimate, z$p.value)}))
tt[, 1] <- tt[, 1] - tt[, 2]
tt <- tt[, -2]
tt <- cbind(symbol=data[, 1], as.data.frame(tt), rank=NA)
tt[, 3] <- -log(tt[, 3], 10)
colnames(tt)[2:3] <- c("log.ratio", "neg.log(t.test)")
tt[, 4] <- sqrt(tt[, 2]^4 tt[, 3]^2)
tt <- tt[order(tt[, 4], decreasing=T), ]
tt
}
Error: unexpected symbol in "tt[, 4] <- sqrt(tt[, 2]^4 tt"
When I am running function as whole says that
Error: unexpected '}' in "}"
When I am putting
tt= volcan(data,cl1,cl2)
and doing line by line going down after
tt[, 4] <- sqrt(tt[, 2]^4 tt[, 3]^2)
Says
Error: unexpected symbol in "tt[, 4] <- sqrt(tt[, 2]^4 tt"
I am not sure why, I put comma in
tt[, 4] <- sqrt(tt[, 2]^4 , tt[, 3]^2)
But another error