comparison dartseq_seeduk_1.R @ 1:a8f30e5859c9 draft

Uploaded
author cropgeeks
date Tue, 17 Apr 2018 08:09:21 -0400
parents
children dde8fec1b31e
comparison
equal deleted inserted replaced
0:0da02ef4141a 1:a8f30e5859c9
1 # yum install gdal-devel libcurl-devel libpng-devel mesa-libGL-devel mesa-libGLU-devel proj-nad proj-epsg
2 #
3 # source("https://bioconductor.org/biocLite.R")
4 # biocLite("SNPRelate")
5 # biocLite("qvalue")
6 #
7 # install.packages("dartR")
8 # install.packages("amap")
9
10 args = commandArgs(trailingOnly=TRUE)
11
12
13 library("dartR")
14
15 #Read DarT data
16 gl <- gl.read.dart(filename=args[1], nas = "-", topskip = 5, lastmetric = "TotalPicRepSnpTest", probar = TRUE)
17
18 #Trying to determine if one row or two row format...
19 #Found 2 row(s) format. Proceed...
20 #Added the following covmetrics:
21 #AlleleID CloneID ClusterTempIndex AlleleSequence ClusterConsensusSequence ClusterSize AlleleSeqDist SNP SnpPosition CallRate OneRatioRef OneRatioSnp FreqHomRef FreqHomSnp FreqHets PICRef PICSnp AvgPIC AvgCountRef AvgCountSnp RatioAvgCountRefAvgCountSnp FreqHetsMinusFreqMinHom AlleleCountsCorrelation aggregateTagsTotal DerivedCorrMinusSeedCorr RepRef RepSNP RepAvg PicRepRef PicRepSNP TotalPicRepRefTest TotalPicRepSnpTest .
22 #Number of rows per Clone. Should be only 2 s: 2
23 # Recognised: 376 individuals and 113138 SNPs in a 2 row format using /data/projects/seed/dart_calls/BBSRC-Panel-DArTSEQ-SNPs.csv
24 #Start conversion....
25 #Format is 2 rows.
26 #Please note conversion of bigger data sets will take some time!
27 #Once finished, we recommend to save the object using save(object, file="object.rdata")
28 # |======================================================================| 100%
29 #>
30 gl.report.callrate(gl)
31 #Reporting for a genlight object
32 #Note: Missing values most commonly arise from restriction site mutation.
33
34 # Loci with no missing values = 499 [0.4%]
35 # < 5% missing values = 23669 [20.9%]
36 # < 10% missing values = 45298 [40%]
37 # < 15% missing values = 60678 [53.6%]
38 # < 20% missing values = 72478 [64.1%]
39 # < 25% missing values = 81629 [72.1%]
40 # < 30% missing values = 89227 [78.9%]
41 # < 35% missing values = 95969 [84.8%]
42 # < 40% missing values = 101973 [90.1%]
43 # < 45% missing values = 107590 [95.1%]
44 # < 50% missing values = 113138 [100%]
45 #[1] "Completed"
46 gl.report.callrate(gl,method='ind' )
47 #Reporting for a genlight object
48 #Note: Missing values most commonly arise from restriction site mutation.
49
50 #Individuals no missing values = 0 [0%] across loci
51 #Individuals with less than 5% missing values = 1 [0.3%]
52 #Individuals with less than 10% missing values = 73 [19.4%]
53 #Individuals with less than 15% missing values = 194 [51.6%]
54 #Individuals with less than 20% missing values = 268 [71.3%]
55 #Individuals with less than 25% missing values = 320 [85.1%]
56 #Individuals with less than 30% missing values = 341 [90.7%]
57 #Individuals with less than 35% missing values = 352 [93.6%]
58 #Individuals with less than 40% missing values = 358 [95.2%]
59 #Individuals with less than 45% missing values = 366 [97.3%]
60 #Individuals with less than 50% missing values = 371 [98.7%]
61 #Individuals with less than 55% missing values = 372 [98.9%]
62 #Individuals with less than 60% missing values = 374 [99.5%]
63 #Individuals with less than 65% missing values = 375 [99.7%]
64 #[1] "Completed"
65 #
66 #
67 gl_call_rate <- gl.filter.callrate(gl,method = 'loc', t=0.75)
68 #Reporting for a genlight object
69 #Note: Missing values most commonly arise from restriction site mutation.
70 #
71 #Initial no. of loci = 113138
72 # No. of loci deleted = 31509
73 #Summary of filtered dataset
74 # Call Rate > 0.75
75 # No. of loci: 81629
76 # No. of individuals: 376
77 # No. of populations: 0
78 #
79 gl_rep <- gl.filter.repavg(gl_call_rate,t=0.98)
80 #Reporting for a genlight object
81 #Note: RepAvg is a DArT statistic reporting reproducibility averaged across alleles for each locus.
82
83 #Initial no. of loci = 81629
84 #No. of loci deleted = 6446
85 #Summary of filtered dataset
86 # Reproducibility >= 0.98
87 # No. of loci: 75183
88 # No. of individuals: 376
89 # No. of populations: 0
90
91 gl.report.callrate(gl_rep,method='ind' )
92 #Reporting for a genlight object
93 #Note: Missing values most commonly arise from restriction site mutation.
94
95 #Individuals no missing values = 0 [0%] across loci
96 #Individuals with less than 5% missing values = 161 [42.8%]
97 #Individuals with less than 10% missing values = 245 [65.2%]
98 #Individuals with less than 15% missing values = 301 [80.1%]
99 #Individuals with less than 20% missing values = 337 [89.6%]
100 #Individuals with less than 25% missing values = 347 [92.3%]
101 #Individuals with less than 30% missing values = 358 [95.2%]
102 #Individuals with less than 35% missing values = 359 [95.5%]
103 #Individuals with less than 40% missing values = 364 [96.8%]
104 #Individuals with less than 45% missing values = 372 [98.9%]
105 #Individuals with less than 50% missing values = 373 [99.2%]
106 #Individuals with less than 55% missing values = 374 [99.5%]
107 #Individuals with less than 60% missing values = 375 [99.7%]
108 #[1] "Completed"
109
110 gl_final <- gl.filter.callrate(gl_rep,method = 'ind', t=0.8)
111 #Reporting for a genlight object
112 #Note: Missing values most commonly arise from restriction site mutation.
113
114 #Initial no. of individuals = 376
115 #Filtering a genlight object
116 # no. of individuals deleted = 39
117 #Individuals retained = 337
118 #List of individuals deleted because of low call rate
119 # 908017247001_E_5 908017247001_F_4 908017247002_A_10 908017247002_B_4 908017247002_B_5 908017247002_C_3 908017247002_D_12 908017247002_D_2 908017247002_D_6 908017247002_D_9 908017247002_E_6 908017247002_E_7 908017247002_E_9 908017247002_F_2 908017247002_F_6 908017247002_G_8 908017247002_H_10 908017247002_H_7 908017247002_H_8 908017247003_B_8 908017247003_C_8 908017247003_D_8 908017247003_E_8 908017247003_F_8 908017247003_G_6 908017247003_G_8 908017247003_H_7 908017247004_C_11 908017247004_D_11 908017247004_D_8 908017247004_D_9 908017247004_E_10 908017247004_E_11 908017247004_E_9 908017247004_F_11 908017247004_F_12 908017247004_F_6 908017247004_G_11 908017247004_H_11
120 # from populations
121
122 #Summary of filtered dataset
123 # Call Rate > 0.8
124 # No. of loci: 75183
125 # No. of individuals: 337
126 # No. of populations: 0
127 #
128 gl2gds(gl_final,outfile="gl2gds.gds")
129 #Converting gl object to gds formatted file gl2gds.gds
130
131 #Structure of gds file
132
133 #The file name: /data/projects/seed/dart_calls/gl2gds.gds
134 #The total number of samples: 268
135 #The total number of SNPs: 113138
136 #SNP genotypes are stored in SNP-major mode (Sample X SNP).
137 #The SNP positions are not in ascending order on chromosome 1.
138 #File: /data/projects/seed/dart_calls/gl2gds.gds (32.8M)
139 #+ [ ] *
140 #|--+ https://protect-eu.mimecast.com/s/cfduCj27LTYnmOHWrcoC?domain=sample.id { Str8 268 ZIP_ra(13.7%), 641B }
141 #|--+ https://protect-eu.mimecast.com/s/byfzCk59DIkOBwfVgChE?domain=snp.id { Str8 113138 ZIP_ra(37.9%), 637.3K }
142 #|--+ https://protect-eu.mimecast.com/s/0diWClOjDH12EMtyg-Gp?domain=snp.rs.id { Int32 113138 ZIP_ra(78.4%), 346.6K }
143 #|--+ snp.position { Float64 113138 ZIP_ra(14.9%), 131.5K }
144 #|--+ snp.chromosome { Int32 113138 ZIP_ra(0.10%), 481B }
145 #|--+ snp.allele { Str8 113138 ZIP_ra(14.4%), 63.6K }
146 #|--+ genotype { Bit2 268x113138, 7.2M } *
147 #\--+ loc.metrics [ data.frame ] *
148 # |--+ AlleleID { Int32,factor 113138 ZIP_ra(68.9%), 304.3K } *
149 # |--+ CloneID { Int32 113138 ZIP_ra(78.4%), 346.6K }
150 # |--+ ClusterTempIndex { Int32 113138 ZIP_ra(63.6%), 281.1K }
151 # |--+ AlleleSequence { Int32,factor 113138 ZIP_ra(68.9%), 304.4K } *
152 # |--+ ClusterConsensusSequence { Int32,factor 113138 ZIP_ra(66.2%), 292.5K } *
153 # |--+ ClusterSize { Int32 113138 ZIP_ra(7.27%), 32.1K }
154 # |--+ AlleleSeqDist { Int32 113138 ZIP_ra(8.49%), 37.5K }
155 # |--+ SNP { Int32,factor 113138 ZIP_ra(38.3%), 169.2K } *
156 # |--+ SnpPosition { Int32 113138 ZIP_ra(26.0%), 115.1K }
157 # |--+ CallRate { Float64 113138 ZIP_ra(2.84%), 25.1K }
158 # |--+ OneRatioRef { Float64 113138 ZIP_ra(32.7%), 289.2K }
159 # |--+ OneRatioSnp { Float64 113138 ZIP_ra(36.1%), 318.8K }
160 # |--+ FreqHomRef { Float64 113138 ZIP_ra(36.6%), 323.6K }
161 # |--+ FreqHomSnp { Float64 113138 ZIP_ra(32.6%), 288.4K }
162 # |--+ FreqHets { Float64 113138 ZIP_ra(20.0%), 177.2K }
163 # |--+ PICRef { Float64 113138 ZIP_ra(29.9%), 264.1K }
164 # |--+ PICSnp { Float64 113138 ZIP_ra(33.7%), 297.7K }
165 # |--+ AvgPIC { Float64 113138 ZIP_ra(44.0%), 388.6K }
166 # |--+ AvgCountRef { Float64 113138 ZIP_ra(55.3%), 489.1K }
167 # |--+ AvgCountSnp { Float64 113138 ZIP_ra(36.6%), 323.8K }
168 # |--+ RatioAvgCountRefAvgCountSnp { Float64 113138 ZIP_ra(57.6%), 509.2K }
169 # |--+ FreqHetsMinusFreqMinHom { Float64 113138 ZIP_ra(31.6%), 279.2K }
170 # |--+ AlleleCountsCorrelation { Float64 113138 ZIP_ra(48.2%), 425.8K }
171 # |--+ aggregateTagsTotal { Int32 113138 ZIP_ra(0.10%), 481B }
172 # |--+ DerivedCorrMinusSeedCorr { Int32 113138 ZIP_ra(0.10%), 478B }
173 # |--+ RepRef { Float64 113138 ZIP_ra(2.50%), 22.1K }
174 # |--+ RepSNP { Float64 113138 ZIP_ra(2.56%), 22.7K }
175 # |--+ RepAvg { Float64 113138 ZIP_ra(0.38%), 3.4K }
176 # |--+ PicRepRef { Float64 113138 ZIP_ra(3.02%), 26.7K }
177 # |--+ PicRepSNP { Float64 113138 ZIP_ra(3.59%), 31.7K }
178 # |--+ TotalPicRepRefTest { Int32 113138 ZIP_ra(9.95%), 44.0K }
179 # |--+ TotalPicRepSnpTest { Int32 113138 ZIP_ra(10.2%), 45.2K }
180 # |--+ clone { Int32,factor 113138 ZIP_ra(67.8%), 299.5K } *
181 # \--+ uid { Int32,factor 113138 ZIP_ra(68.9%), 304.3K } *
182 #NULL
183
184 #Workaround to convert Dart format to 0-1-2 format
185 library("SNPRelate")
186 genofile <- snpgdsOpen("./gl2gds.gds")
187 snpgdsGDS2BED(genofile, bed.fn="test", snp.id=snpset)
188 #Error in .InitFile(gdsobj, https://protect-eu.mimecast.com/s/cfduCj27LTYnmOHWrcoC?domain=sample.id = https://protect-eu.mimecast.com/s/cfduCj27LTYnmOHWrcoC?domain=sample.id, https://protect-eu.mimecast.com/s/byfzCk59DIkOBwfVgChE?domain=snp.id = https://protect-eu.mimecast.com/s/byfzCk59DIkOBwfVgChE?domain=snp.id) :
189 # object 'snpset' not found
190 snpgdsGDS2BED(genofile, bed.fn="test")
191
192