Hello everyone, The following is a portion of coding that a colleague sent. Given my lack of experience in R, I am not quite sure what the significance of the following arguments. Could anyone help me translate? For context, I am aware of the downloading portion of the script... library(data.table) etc., but am not familiar with the portion pertaining to an1 .
library(data.table) anno = as.data.frame(fread(file = "/rsrch1/bcb/kchen_group/v_mohanty/data/TCGA/450K/mapper.txt", sep ="\t", header = T)) meth = read.table(file = "/rsrch1/bcb/kchen_group/v_mohanty/data/TCGA/27K/GBM.txt", sep ="\t", header = T, row.names = 1) meth = as.matrix(meth) """ the loop just formats the methylation column names to match format""" colnames(meth) = sapply(colnames(meth), function(i){ c1 = strsplit(i,split = '.', fixed = T)[[1]] c1[4] = paste(strsplit(c1[4],split = "",fixed = T)[[1]][1:2],collapse = "") paste(c1,collapse = ".") }) exp = read.table(file = "/rsrch1/bcb/kchen_group/v_mohanty/data/TCGA/RNAseq/GBM.txt", sep = "\t", header = T, row.names = 1) exp = as.matrix(exp) c = intersect(colnames(exp),colnames(meth)) exp = exp[,c] meth = meth[,c] m = apply(meth, 1, function(i){ log2(i/(1-i)) }) m = t(as.matrix(m)) an = anno[anno$probe %in% rownames(m),] an = an[an$gene %in% rownames(exp),] an = an[an$location %in% c("TSS200","TSS1500"),] p = apply(an,1,function(i){ tryCatch(summary(lm(exp[as.character(i[2]),] ~ m[as.character(i[1]),]))$coefficient[2,4], error= function(e)NA) }) t = apply(an,1,function(i){ tryCatch(summary(lm(exp[as.character(i[2]),] ~ m[as.character(i[1]),]))$coefficient[2,3], error= function(e)NA) }) an1 =cbind(an,p) an1 = cbind(an1,t) an1$q = p.adjust(as.numeric(an1$p)) summary(lm(exp["MAOB",] ~ m["cg00121904",]$coefficient[2,c(3:4)] ############################################### [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.