Advertisement
Guest User

Untitled

a guest
Jul 6th, 2015
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.47 KB | None | 0 0
  1. library(ggplot2)
  2. library(reshape2)
  3.  
  4. dat <- structure(list(Type = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
  5. 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L,
  6. 3L, 3L, 3L, 3L, 3L, 3L, 3L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
  7. 6L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L), .Label = c("High_expression",
  8. "KD.ip", "LG.ip", "LN.id", "LV.id", "LV.ip", "SP.id", "SP.ip"
  9. ), class = "factor"), ImmGen = structure(c(1L, 2L, 3L, 4L, 5L,
  10. 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L,
  11. 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L,
  12. 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L), .Label = c("Bcells",
  13. "DendriticCells", "Macrophages", "Monocytes", "NKCells", "Neutrophils",
  14. "StemCells", "StromalCells", "abTcells", "gdTCells"), class = "factor"),
  15. Exp_06hr = c(7174.40482999999, 23058.74882, 39819.39133,
  16. 15846.46146, 8075.78226, 105239.11609, 7606.34563, 19513.57747,
  17. 7116.51211, 6978.64995, 498.36828, 732.01788, 621.51576,
  18. 546.63461, 529.1711, 545.17219, 477.54658, 1170.50303, 550.99528,
  19. 607.56707, 775.0691, 1269.50773, 2138.69883, 1561.74652,
  20. 601.9372, 5515.59896, 744.48716, 997.32859, 639.13126, 657.64581,
  21. 4165.29899, 5465.1883, 7773.25723, 5544.86758, 3461.13442,
  22. 8780.64899, 4380.00437, 8721.84871, 3674.62723, 3911.00108,
  23. 2932.76554, 5903.48407, 6179.81046, 3683.64539, 2744.59622,
  24. 6760.37307, 4097.14665, 6845.31988, 2872.77771, 2912.84262
  25. ), Exp_24hr = c(1596.9091, 4242.52354, 9984.68861, 3519.18627,
  26. 1602.92511, 12203.57109, 1656.19357, 3389.93866, 1617.35484,
  27. 1579.00309, 715.47289, 643.98371, 689.40412, 580.26036, 608.22853,
  28. 695.10737, 830.77947, 670.34899, 640.67908, 637.47464, 356.75713,
  29. 393.13449, 549.60095, 466.76064, 336.95453, 617.20976, 339.2476,
  30. 469.57407, 292.86365, 305.45178, 2604.07605, 4210.64843,
  31. 5797.13123, 3650.88447, 2275.03269, 6475.27485, 2604.70614,
  32. 4796.3314, 2411.09694, 2458.23237, 1498.21516, 1996.6875,
  33. 2927.82836, 1911.00463, 1523.57171, 2199.62297, 1541.82034,
  34. 2815.82184, 1608.46099, 1588.80561), ExpDiff_06_24hr = c(5577.49572999999,
  35. 18816.22528, 29834.70272, 12327.27519, 6472.85715, 93035.545,
  36. 5950.15206, 16123.63881, 5499.15727, 5399.64686, -217.10461,
  37. 88.03417, -67.88836, -33.62575, -79.05743, -149.93518, -353.23289,
  38. 500.15404, -89.6838, -29.9075700000001, 418.31197, 876.37324,
  39. 1589.09788, 1094.98588, 264.98267, 4898.3892, 405.23956,
  40. 527.75452, 346.26761, 352.19403, 1561.22294, 1254.53987,
  41. 1976.126, 1893.98311, 1186.10173, 2305.37414, 1775.29823,
  42. 3925.51731, 1263.53029, 1452.76871, 1434.55038, 3906.79657,
  43. 3251.9821, 1772.64076, 1221.02451, 4560.7501, 2555.32631,
  44. 4029.49804, 1264.31672, 1324.03701)), .Names = c("Type",
  45. "ImmGen", "Exp_06hr", "Exp_24hr", "ExpDiff_06_24hr"), row.names = c(NA,
  46. -50L), class = "data.frame")
  47.  
  48. dat.m <- melt(dat)
  49.  
  50. setwd("~/Desktop/")
  51. pdf("myfig.pdf",width=30,height=20)
  52. p <- ggplot(dat.m,aes(ImmGen,value)) +
  53. geom_bar(aes(fill = variable),position = "dodge",stat="identity")+
  54. facet_wrap(~Type)
  55.  
  56. p
  57. dev.off();
  58.  
  59. dat$rank <- rank(dat$ExpDiff_06_24hr)
  60. dat.m <- melt(dat, id = c("Type","ImmGen","rank"))
  61.  
  62. dat.t <- transform(dat.m, TyIm = factor(paste0(Type, ImmGen)))
  63. dat.t <- transform(dat.t, TyIm = reorder(TyIm, rank(rank)))
  64.  
  65. p <- ggplot(dat.t, aes(TyIm,value)) +
  66. geom_bar(aes(fill = variable), position = "dodge", stat="identity")+
  67. facet_wrap(~Type, ncol=1, scales="free") +
  68. scale_x_discrete("ImmGen", breaks=dat.t$TyIm, labels=dat.t$ImmGen)
  69. p
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement