Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. library(methylKit)
  2.  
  3. setwd("~/Projects/BullsRRBS_Heat_Stress_AUG2016/bismark_aligned/")
  4. list.files()
  5.  
  6. # Get list of files. Here we will read from coverage file output by bismark
  7. files <- list(
  8. "sample_7307_C1_bismark_out/7307_C1_R1_val_1_bismark_pe.bismark.cov",
  9. "sample_7334_C1_bismark_out/7334_C1_R1_val_1_bismark_pe.bismark.cov",
  10. "sample_8062_C1_bismark_out/8062_C1_R1_val_1_bismark_pe.bismark.cov",
  11. "sample_7307_T8_bismark_out/7307_T8_R1_val_1_bismark_pe.bismark.cov",
  12. "sample_7334_T8_bismark_out/7334_T8_R1_val_1_bismark_pe.bismark.cov",
  13. "sample_8062_T8_bismark_out/8062_T8_R1_val_1_bismark_pe.bismark.cov"
  14. )
  15.  
  16. myobj <- methylKit::methRead(files,
  17. sample.id=list("S7307_C1", "S7334_C1", "S8062_C1",
  18. "S7307_T8", "S7334_T8", "S8062_T8"),
  19. treatment=c(0, 0, 0, 1, 1, 1),
  20. context="CpG",
  21. pipeline = "bismarkCoverage",
  22. assembly = "UMD3.1")
  23.  
  24. # Plot methylation percentage histograms for each sample
  25. getMethylationStats(myobj[[1]],plot=TRUE,both.strands=FALSE)
  26. getMethylationStats(myobj[[2]],plot=TRUE,both.strands=FALSE)
  27. getMethylationStats(myobj[[3]],plot=TRUE,both.strands=FALSE)
  28. getMethylationStats(myobj[[4]],plot=TRUE,both.strands=FALSE)
  29. getMethylationStats(myobj[[5]],plot=TRUE,both.strands=FALSE)
  30. getMethylationStats(myobj[[6]],plot=TRUE,both.strands=FALSE)
  31.  
  32. # Plot read coverage for each of the samples
  33. getCoverageStats(myobj[[1]],plot=TRUE,both.strands=FALSE)
  34. getCoverageStats(myobj[[2]],plot=TRUE,both.strands=FALSE)
  35. getCoverageStats(myobj[[3]],plot=TRUE,both.strands=FALSE)
  36. getCoverageStats(myobj[[4]],plot=TRUE,both.strands=FALSE)
  37. getCoverageStats(myobj[[5]],plot=TRUE,both.strands=FALSE)
  38. getCoverageStats(myobj[[6]],plot=TRUE,both.strands=FALSE)
  39.  
  40. # Remove CpG sites with low coverage (below 10 reads) and extremely high coverage > 99.9 percentile
  41. filtered.myobj <- filterByCoverage(myobj,lo.count=10,lo.perc=NULL,
  42. hi.count=NULL,hi.perc=99.9)
  43. norm.myobj <- normalizeCoverage(filtered.myobj, method="median")
  44. # Get CpGs covered in all samples
  45. meth <- unite(norm.myobj, destrand=FALSE)
  46. meth
  47. # We are only comparing 7705 CpGs between Control and Day 8
  48.  
  49. # Plot correlations and scatter plots between samples
  50. getCorrelation(meth,plot=TRUE)
  51.  
  52. # Cluster samples based on correlation. Method "Ward"
  53. clusterSamples(meth, dist="correlation", method="ward", plot=TRUE)
  54.  
  55. # PCA plot
  56. PCASamples(meth)
  57.  
  58. #####################################################################################################################
  59. ## Get differentially methylated CpGs
  60. myDiff <- calculateDiffMeth(meth, num.cores = 4)
  61.  
  62. # Get hyper- and hypo-methylated CpGs
  63. # get hyper methylated bases
  64. myDiff25p.hyper <- getMethylDiff(myDiff,difference=20,qvalue=0.05,type="hyper") # 17 Hyper CpGs
  65. myDiff25p.hyper
  66. # get hypo methylated bases
  67. myDiff25p.hypo <- getMethylDiff(myDiff,difference=20,qvalue=0.05,type="hypo") # 3 Hypo CpGs
  68. myDiff25p.hypo
  69. # get all differentially methylated bases
  70. myDiff25p <- getMethylDiff(myDiff,difference=20,qvalue=0.05) # 20 differentially methylated
  71. myDiff25p
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement