TEXT
58
explore data R
Guest on 23rd April 2022 01:06:21 AM
library(ggplot2)
library(reshape)
tab = read.table('/Volumes/data/martha/Networks/Data/MAGIC_VarComp_gxe_vc-flatfile.txt', h = T)
plot.dir = '/Volumes/data/martha/Networks/Results/'
explore.variance.components <- function(tab, plot.dir = ''){
pdffile = paste(plot.dir, 'exploratory.plots.pdf', sep = '')
pdf(pdffile)
print(tab[1:10,])
df.gen = melt(tab, measure.vars = c('Vcis', 'Vtrans'))
print(head(df.gen))
df.all = melt(tab, measure.vars = c('Vcis', 'VcisGxE', 'Vtrans', 'VtransGxE'))
#plot distribution of cis and trans qtls
p <- ggplot(df.gen) + geom_density(aes(x = value, fill = variable)) + xlab('Genetic variance distribution')
q <- ggplot(tab) + geom_point(aes(x = Vcis, y = Vtrans)) + xlab('Vcis') + ylab('Vtrans')
r <- ggplot(df.all) + geom_boxplot(aes(x = variable, y = value, fill = variable))
h <- ggplot(tab) + geom_histogram(aes(x = Vtrans), binwidth = 0.01)
print(p)
print(q)
print(r)
print(h)
dev.off()
}
explore.variance.components(tab, plot.dir)