viewing paste Unknown #21903 | R / S+

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
# =============================== Load Library ===============================
library('R.matlab')
library('reshape2')
library('doBy')
library('grid')
library('ggplot2')
library('dplyr')
library('tidyr') 
library('caret')
library('e1071')
 
# ------------------------------ Read real data ------------------------------
timeGen = readRDS('timeGen_s4.RDS')
 
# ----------------------------- Process real data ----------------------------
timeGen_mean = timeGen %>% 
  group_by(timeGen, time, TestTime) %>% 
  summarise(acc = mean(acc)) %>% 
  ungroup()
 
# --------------------- Make Grid reference to read data ---------------------
iGrid = expand.grid(ic = 1:36, ip = 1:100) %>% as.tbl()
 
condiPair = data.frame(c1 = c(111, 115, 112, 116, 114, 118),
                       c2 = c(125, 121, 126, 122, 128, 124))
condiPair_h = condiPair
 
geneTable = condiPair_h %>% 
  group_by(c1, c2) %>% 
  do(condiPair_h %>% rename(g1 = c1, g2= c2)) %>%
  ungroup()
 
# ----------------------------------------------------------------------------
geneTable$ind = 1:nrow(geneTable)
iPlotCondi = geneTable %>% filter(c1 == condiPair$c1[6], c2 == condiPair$c2[6])
iPlotCondi = iPlotCondi$ind
 
 
 
# ------------------------------ Read perm data ------------------------------
timeGen.perm = iGrid %>% 
  filter(ic %in% iPlotCondi) %>%
  rowwise() %>% 
  do( readRDS(sprintf('perm\\timeGen_perm_c%d_r%d.RDS', .$ic, .$ip)) )
 
 
# ---------------------------- calculate perm data ---------------------------
timeGen.perm.summary = timeGen.perm %>%
  ungroup %>%
  group_by(time, TestTime, timeGen) %>%
  summarise(CI = quantile(acc, .95), sd = sd(acc), acc_perm = mean(acc))
 
 
# ----------------------------------------------------------------------------
timeGen.plot = timeGen.perm.summary %>% 
  left_join(timeGen_mean) %>% 
  ungroup() %>%
  mutate(isSig = as.integer(acc > CI))
 
# ----------------------------------------------------------------------------
ggplot(timeGen.plot, aes(TestTime, time, fill = acc)) + 
  geom_tile( colour = "black" ) + 
  # scale_fill_gradientn(colours = colorRamps::matlab.like2(100)) + 
  geom_tile( aes(fill=isSig)) +
  facet_wrap(~timeGen, ncol = 3) + 
  coord_fixed() 
 
Viewed 928 times, submitted by Guest.