TEXT   58

explore data R

Guest on 23rd April 2022 01:06:21 AM

  1. library(ggplot2)
  2. library(reshape)
  3. tab = read.table('/Volumes/data/martha/Networks/Data/MAGIC_VarComp_gxe_vc-flatfile.txt', h = T)
  4. plot.dir = '/Volumes/data/martha/Networks/Results/'
  5.  
  6. explore.variance.components <- function(tab, plot.dir = ''){
  7.   pdffile = paste(plot.dir, 'exploratory.plots.pdf', sep = '')
  8.   pdf(pdffile)
  9.   print(tab[1:10,])
  10.   df.gen = melt(tab, measure.vars = c('Vcis', 'Vtrans'))
  11.   print(head(df.gen))
  12.   df.all = melt(tab, measure.vars = c('Vcis', 'VcisGxE', 'Vtrans', 'VtransGxE'))
  13.   #plot distribution of cis and trans qtls
  14.   p <- ggplot(df.gen) + geom_density(aes(x = value, fill = variable)) + xlab('Genetic variance distribution')
  15.   q <- ggplot(tab) + geom_point(aes(x = Vcis, y = Vtrans)) + xlab('Vcis') + ylab('Vtrans')
  16.   r <- ggplot(df.all) + geom_boxplot(aes(x = variable, y = value, fill = variable))
  17.   h <- ggplot(tab) + geom_histogram(aes(x = Vtrans), binwidth = 0.01)
  18.   print(p)
  19.   print(q)
  20.   print(r)
  21.   print(h)
  22.   dev.off()
  23. }
  24.  
  25. explore.variance.components(tab, plot.dir)

Raw Paste


Login or Register to edit or fork this paste. It's free.