Guest User

Untitled

a guest
Jun 20th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.08 KB | None | 0 0
  1. > str(segments)
  2. 'data.frame': 11897 obs. of 7 variables:
  3. $ X : int 0 1 2 3 4 5 6 7 8 9 ...
  4. $ SegmentID : int 72 73 74 75 76 77 78 79 80 81 ...
  5. $ Chromosome : int 1 1 2 2 2 3 3 3 3 3 ...
  6. $ StartPosition : int 754192 145260908 21494 141215321 141275624 63411 69812903 69884262 126473310 126790130 ...
  7. $ StopPosition : int 145258178 249212878 141214996 141275051 243052331 69811900 69884106 126457276 126772699 197852564 ...
  8. $ Median.Log2.Ratio: num -0.014 0.311 -0.003 0.059 -0.012 -0.018 -0.106 0.007 -0.171 0.001 ...
  9. $ FileName : Factor w/ 95 levels "TSB02183","TSB02184",..: 1 1 1 1 1 1 1 1 1 1 ..
  10.  
  11. > segments <- read.csv("Probe_Segments_CN.csv")
  12. > cnseg <- CNSeg(segList = segments, chromosome = "Chromosome", end = "StopPosition", start = "StartPosition", segMean = "Median.Log2.Ratio", id = "FileName")
  13. > rdseg <- getRS(cnseg, by = "region", imput = FALSE, XY = FALSE, what = "mean")
  14. Processing samples ... Done
  15. > data("geneInfo")
  16. > geneInfo <- geneInfo[sample(1:nrow(geneInfo), 2000), ]
  17. >
  18. > rdByGene <- getRS(cnseg, by = "gene", imput = FALSE, XY = FALSE, geneMap = geneInfo, what = "median")
  19. >
  20. > reducedseg <- rs(rdseg)
  21. > f1 <- kOverA(5, 1)
  22. >
  23. > ffun <- filterfun(f1)
  24. >
  25. > filteredrs <- genefilter(rdseg, ffun)
  26. > filteredrs <- madFilter(rdseg, 0.8)
  27. > dist(filteredrs)
  28. Error in as.vector(data) :
  29. no method for coercing this S4 class to a vector
  30. > sessionInfo()
  31. R version 3.4.0 (2017-04-21)
  32. Platform: x86_64-w64-mingw32/x64 (64-bit)
  33. Running under: Windows >= 8 x64 (build 9200)
  34.  
  35. Matrix products: default
  36.  
  37. locale:
  38. [1] LC_COLLATE=English_United States.1252
  39. [2] LC_CTYPE=English_United States.1252
  40. [3] LC_MONETARY=English_United States.1252
  41. [4] LC_NUMERIC=C
  42. [5] LC_TIME=English_United States.1252
  43.  
  44. attached base packages:
  45. [1] tools stats graphics grDevices
  46. [5] utils datasets methods base
  47.  
  48. other attached packages:
  49. [1] CNTools_1.34.0 genefilter_1.60.0
  50.  
  51. loaded via a namespace (and not attached):
  52. [1] Rcpp_0.12.17 AnnotationDbi_1.40.0
  53. [3] BiocGenerics_0.24.0 splines_3.4.0
  54. [5] IRanges_2.12.0 bit_1.1-14
  55. [7] lattice_0.20-35 xtable_1.8-2
  56. [9] blob_1.1.1 parallel_3.4.0
  57. [11] grid_3.4.0 Biobase_2.38.0
  58. [13] DBI_1.0.0 survival_2.41-3
  59. [15] bit64_0.9-7 digest_0.6.15
  60. [17] Matrix_1.2-9 S4Vectors_0.16.0
  61. [19] bitops_1.0-6 RCurl_1.95-4.10
  62. [21] memoise_1.1.0 RSQLite_2.1.1
  63. [23] compiler_3.4.0 stats4_3.4.0
  64. [25] XML_3.98-1.11 annotate_1.56.2
  65.  
  66. require(CNTools)
  67. segData <- read.csv("result_cnv.csv", stringsAsFactors = FALSE)
  68. head(segData)
  69.  
  70. # Create inital CN object
  71. cnseg <- CNSeg(segList = segData, chromosome = "Chromosome", end = "StopPosition", start = "StartPosition", segMean = "Median.Log2.Ratio", id = "FileName")
  72. cnseg
  73.  
  74. # Create inital RD object
  75. rdseg <- getRS(cnseg, by = "region", imput = FALSE, XY = FALSE, what = "mean")
  76. rdseg
  77.  
  78. # Collect gene information
  79. data("geneInfo")
  80. geneInfo <- geneInfo[sample(1:nrow(geneInfo), 2000), ]
  81.  
  82. # Create an RD based on gene information
  83. rdByGene <- getRS(cnseg, by = "gene", imput = FALSE, XY = FALSE, geneMap = geneInfo, what = "median")
  84.  
  85. # Initalize reduced segment
  86. reducedseg <- rs(rdseg)
  87.  
  88. # Create a function that evaluates to TRUE if at least 5 of the argument elements are larger than 1
  89. f1 <- kOverA(5, 1)
  90.  
  91. # Create a filter based on f1
  92. ffun <- filterfun(f1)
  93.  
  94. # Use the CNTools genefilter
  95. filteredrs <- genefilter(rdseg, ffun)
  96.  
  97. # Use the CNTools madFilter
  98. filteredrs <- madFilter(rdseg, 0.8)
  99.  
  100. filteredrs
  101.  
  102. # Write the filtered data to file
  103. write.csv(attributes(filteredrs)[1], "CNseg_CNOut.csv")
  104.  
  105. # Reading the recently-written file helps with formatting
  106. CNseg <- read.csv("CNseg_CNOut.csv")
  107.  
  108. # Keep only the columns with actual sample values
  109. CNseg <- CNseg[5:ncol(CNseg)]
  110.  
  111. # Calculate eluclidian distance between samples
  112. d <- dist(t(CNseg), method = "euclidean")
  113.  
  114. # Calculate clustering
  115. hc1 <- hclust(d, method = "ward.D")
  116. plot(hc1, cex = 0.6, hang = -1, main = "Clusters of Copy Number Alterations", xlab = "Euclidean Distance")
Add Comment
Please, Sign In to add comment