Skip to content

Commit b816a26

Browse files
author
Fernando Gelin
authored
Merge pull request #8 from compbiocore/solve_memory_allocation_issue
Finished most tests. Fixed siglist filter functions.
2 parents 36ab770 + ff801a2 commit b816a26

File tree

11 files changed

+319
-422
lines changed

11 files changed

+319
-422
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
*.html
66
.DS_Store
77
.ipynb_checkpoints/
8+
output

.travis.yml

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
1-
## Documentation: http://docs.travis-ci.com/user/languages/julia/
21
language: julia
32

4-
# os:
5-
# - linux
6-
# - osx
7-
#
8-
# julia:
9-
# - 0.6
10-
#
11-
# notifications:
12-
# email: false
13-
#
14-
# git:
15-
# depth: 99999999
16-
#
17-
# before_script:
18-
# - export PATH=$HOME/.local/bin:$PATH
3+
os:
4+
- linux
5+
- osx
196

20-
# after_success:
21-
# - julia -e 'import Pkg; Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
7+
julia:
8+
- 0.6
9+
10+
notifications:
11+
email: false
12+
13+
git:
14+
depth: 99999999
15+
16+
before_script:
17+
- export PATH=$HOME/.local/bin:$PATH
18+
19+
script:
20+
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
21+
- julia --check-bounds=yes -e 'Pkg.clone(pwd()); Pkg.pin("Blink", v"0.6.2"); Pkg.pin("PlotlyJS", v"0.10.2"); Pkg.build("Blink"); Pkg.build("ViVa"); Pkg.test("ViVa"; coverage=true)'
22+
23+
after_success:
24+
- julia -e 'Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
2225

2326
jobs:
2427
include:

ViVa_v2.jl

Lines changed: 0 additions & 15 deletions
This file was deleted.

open_jupyter_notebook.jl

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/ViVa.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
module ViVa
22

3-
using DataFrames #use CSV.jl ? depwarnings
3+
using DataFrames
44
using PlotlyJS
55
using Rsvg
66
using Blink
7-
using CSV
87
using GeneticVariation
98
using ArgParse
10-
using VCFTools
9+
#using VCFTools
10+
#using Base.Filesystem
1111

1212

1313

@@ -42,9 +42,9 @@ export
4242
avg_variant_dp_line_chart,
4343
read_depth_threshhold,
4444
list_variant_positions_low_dp,
45-
list_sample_positions_low_dp,
45+
list_sample_names_low_dp,
4646
avg_dp_variant,
47-
avg_dp_patients,
47+
avg_dp_samples,
4848
jupyter_main,
4949
save_numerical_array,
5050
io_pass_filter,

src/plot_utils.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ function genotype_heatmap2(input,title,chrom_label_info,sample_names)
4242
end
4343

4444
"""
45-
genotype_heatmap_with_groups(input::Array{Int64,2},title::String,chrom_label_info::Tuple{Array{String,1},Array{Int64,1},String},group_label_pack::Array{Any,1},sample_names)
46-
generate heatmap of genotype data.
45+
genotype_heatmap_with_groups(input::Array{Int64,2},title::String,chrom_label_info::Tuple{Array{String,1},Array{Int64,1},String},group_label_pack::Array{Any,1},sample_names)
46+
generate heatmap of genotype data.
4747
"""
4848
function genotype_heatmap_with_groups(input::Array{Int64,2},title::String,chrom_label_info::Tuple{Array{String,1},Array{Int64,1},String},group_label_pack::Array{Any,1},sample_names)
4949

@@ -127,7 +127,7 @@ function dp_heatmap2(input, title, chrom_label_info, sample_names)
127127
end
128128

129129
"""
130-
dp_heatmap2_with_groups(input::Array{Int64,2},title::String,chrom_label_info::Tuple{Array{String,1},Array{Int64,1},String},group_label_pack::Array{Any,1})
130+
dp_heatmap2_with_groups(input::Array{Int64,2},title::String,chrom_label_info::Tuple{Array{String,1},Array{Int64,1},String},group_label_pack::Array{Any,1})
131131
generate heatmap of read depth data with grouped samples.
132132
"""
133133
function dp_heatmap2_with_groups(input::Array{Int64,2},title::String,chrom_label_info::Tuple{Array{String,1},Array{Int64,1},String},group_label_pack::Array{Any,1})
@@ -174,7 +174,7 @@ function dp_heatmap2_with_groups(input::Array{Int64,2},title::String,chrom_label
174174
end
175175

176176
"""
177-
avg_sample_dp_scatter(sample_avg_list::Array{Float64,1},sample_names)
177+
avg_sample_dp_scatter(sample_avg_list::Array{Float64,1},sample_names)
178178
generate line chart of average read depths of each sample.
179179
"""
180180
function avg_sample_dp_scatter(sample_avg_list::Array{Float64,1},sample_names)

src/vcf_utils_complete.jl

Lines changed: 69 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ function sort_genotype_array(genotype_array)
5151
data=genotype_array[:,3:size(genotype_array,2)]
5252
chrom_positions = [parse(Int, i) for i in genotype_array[:,1:2]]
5353
genotype_array = hcat(chrom_positions,data)
54-
5554
genotype_array = sortrows(genotype_array, by=x->(x[1],x[2]))
5655

5756
return genotype_array
@@ -111,38 +110,37 @@ end
111110
io_sig_list_vcf_filter(sig_list,vcf_filename)
112111
returns subarray of variant records matching a list of variant positions returned from load_siglist()
113112
"""
114-
function io_sig_list_vcf_filter(sig_list,vcf_filename)
115-
116-
vcf_subarray = Array{Any}(0)
113+
function io_sig_list_vcf_filter(sig_list,vcf_filename)
117114

118-
for row= 1:size(sig_list,1)
119-
dimension = size(sig_list,1)
115+
reader = VCF.Reader(open(vcf_filename, "r"))
120116

121-
chr=(sig_list[row,1])
122-
pos=(sig_list[row,2])
117+
vcf_subarray = Array{Any}(0)
123118

124-
reader = VCF.Reader(open(vcf_filename, "r"))
119+
for record in reader
125120

126-
for record in reader
121+
for row= 1:size(sig_list,1)
122+
dimension = size(sig_list,1)
127123

128-
if typeof(VCF.chrom(record)) == String
129-
chr = string(chr)
124+
chr=(sig_list[row,1])
125+
pos=(sig_list[row,2])
130126

131-
if (VCF.chrom(record) == chr) && (VCF.pos(record) == pos)
132-
push!(vcf_subarray,record)
133-
end
127+
if typeof(VCF.chrom(record)) == String
128+
chr = string(chr)
129+
if (VCF.chrom(record) == chr) && (VCF.pos(record) == pos)
130+
push!(vcf_subarray,record)
131+
end
134132

135-
else
133+
else
136134

137-
if (VCF.chrom(record) == chr) && (VCF.pos(record) == pos)
138-
push!(vcf_subarray,record)
135+
if (VCF.chrom(record) == chr) && (VCF.pos(record) == pos)
136+
push!(vcf_subarray,record)
139137

140-
end
141-
end
138+
end
142139
end
143-
end
140+
end
141+
end
144142

145-
return vcf_subarray
143+
return vcf_subarray
146144
end
147145

148146
"""
@@ -183,16 +181,16 @@ function pass_chrrange_siglist_filter(vcf_filename,sig_list,chr_range::AbstractS
183181

184182
vcf_subarray = Array{Any}(0)
185183

186-
for row= 1:size(sig_list,1)
184+
reader = VCF.Reader(open(vcf_filename, "r"))
185+
186+
for record in reader
187+
188+
for row = 1:size(sig_list,1)
187189
dimension = size(sig_list,1)
188190

189191
chr=(sig_list[row,1])
190192
pos=(sig_list[row,2])
191193

192-
reader = VCF.Reader(open(vcf_filename, "r"))
193-
194-
for record in reader
195-
196194
if typeof(VCF.chrom(record)) == String
197195
chr = string(chr)
198196

@@ -255,23 +253,23 @@ returns subarray of vcf records with io_pass_filter and io_chromosome_range_vcf_
255253
end
256254

257255
"""
258-
pass_siglist_filter(vcf_filename,sig_list,chr_range::AbstractString)
259-
returns subarray of vcf records with io_pass_filter, io_sig_list_vcf_filter, and io_chromosome_range_vcf_filter applied.
256+
pass_siglist_filter(vcf_filename,sig_list,chr_range::AbstractString)
257+
returns subarray of vcf records with io_pass_filter, io_sig_list_vcf_filter, and io_chromosome_range_vcf_filter applied.
260258
"""
261-
function pass_siglist_filter(vcf_filename,sig_list)
259+
function pass_siglist_filter(vcf_filename,sig_list)
262260

263-
vcf_subarray = Array{Any}(0)
261+
vcf_subarray = Array{Any}(0)
262+
263+
reader = VCF.Reader(open(vcf_filename, "r"))
264+
265+
for record in reader
264266

265267
for row= 1:size(sig_list,1)
266268
dimension = size(sig_list,1)
267269

268270
chr=(sig_list[row,1])
269271
pos=(sig_list[row,2])
270272

271-
reader = VCF.Reader(open(vcf_filename, "r"))
272-
273-
for record in reader
274-
275273
if typeof(VCF.chrom(record)) == String
276274
chr = string(chr)
277275

@@ -283,64 +281,63 @@ returns subarray of vcf records with io_pass_filter and io_chromosome_range_vcf_
283281

284282
if (VCF.chrom(record) == chr) && (VCF.pos(record) == pos) && (VCF.hasfilter(record)) && (VCF.filter(record) == String["PASS"])
285283
push!(vcf_subarray,record)
286-
287284
end
288285
end
289-
end
290286
end
287+
end
291288

292-
return vcf_subarray
293-
end
289+
return vcf_subarray
290+
end
294291

295292
"""
296293
chrrange_siglist_filter(vcf_filename,sig_list,chr_range::AbstractString)
297294
returns subarray of vcf records with io_pass_filter, io_sig_list_vcf_filter, and io_chromosome_range_vcf_filter applied.
298295
"""
299-
function chrrange_siglist_filter(vcf_filename,sig_list,chr_range::AbstractString)
296+
function chrrange_siglist_filter(vcf_filename,sig_list,chr_range::AbstractString)
300297

301-
a=split(chr_range,":")
302-
chrwhole=a[1]
303-
chrnumber=split(chrwhole,"r")
304-
string_chr=chrnumber[2]
305-
chr=String(string_chr)
306-
range=a[2]
307-
splitrange=split(range, "-")
308-
lower_limit=splitrange[1]
309-
chr_range_low=parse(lower_limit)
310-
upper_limit=splitrange[2]
311-
chr_range_high=parse(upper_limit)
298+
a=split(chr_range,":")
299+
chrwhole=a[1]
300+
chrnumber=split(chrwhole,"r")
301+
string_chr=chrnumber[2]
302+
chr=String(string_chr)
303+
range=a[2]
304+
splitrange=split(range, "-")
305+
lower_limit=splitrange[1]
306+
chr_range_low=parse(lower_limit)
307+
upper_limit=splitrange[2]
308+
chr_range_high=parse(upper_limit)
312309

313-
vcf_subarray = Array{Any}(0)
310+
vcf_subarray = Array{Any}(0)
314311

315-
for row= 1:size(sig_list,1)
316-
dimension = size(sig_list,1)
312+
reader = VCF.Reader(open(vcf_filename, "r"))
317313

318-
chr=(sig_list[row,1])
319-
pos=(sig_list[row,2])
314+
for record in reader
320315

321-
reader = VCF.Reader(open(vcf_filename, "r"))
316+
for row= 1:size(sig_list,1)
317+
dimension = size(sig_list,1)
322318

323-
for record in reader
319+
chr=(sig_list[row,1])
320+
pos=(sig_list[row,2])
324321

325-
if typeof(VCF.chrom(record)) == String
326-
chr = string(chr)
322+
if typeof(VCF.chrom(record)) == String
323+
chr = string(chr)
327324

328-
if (VCF.chrom(record) == chr) && (VCF.pos(record) == pos) && ((VCF.chrom(record) == chr)) && ((chr_range_high > VCF.pos(record) > chr_range_low))
329-
push!(vcf_subarray,record)
330-
end
325+
if (VCF.chrom(record) == chr) && (VCF.pos(record) == pos) && ((VCF.chrom(record) == chr)) && ((chr_range_high > VCF.pos(record) > chr_range_low))
326+
push!(vcf_subarray,record)
327+
end
331328

332-
else
329+
else
333330

334-
if (VCF.chrom(record) == chr) && (VCF.pos(record) == pos) && ((VCF.chrom(record) == chr)) && ((chr_range_high > VCF.pos(record) > chr_range_low))
335-
push!(vcf_subarray,record)
331+
if (VCF.chrom(record) == chr) && (VCF.pos(record) == pos) && ((VCF.chrom(record) == chr)) && ((chr_range_high > VCF.pos(record) > chr_range_low))
332+
push!(vcf_subarray,record)
336333

337-
end
338-
end
339-
end
334+
end
335+
end
340336
end
337+
end
341338

342-
return vcf_subarray
343-
end
339+
return vcf_subarray
340+
end
344341

345342
#functions for converting vcf record array to numerical array
346343

@@ -367,9 +364,7 @@ convert sub from variant filters to gt_num_array and gt_chromosome_labels for pl
367364
"""
368365
function combined_all_genotype_array_functions(sub)
369366
genotype_array = generate_genotype_array(sub,"GT")
370-
371367
map!(s->replace(s, "chr", ""), genotype_array, genotype_array)
372-
373368
clean_column1!(genotype_array)
374369
genotype_array=ViVa.sort_genotype_array(genotype_array)
375370
geno_dict = define_geno_dict()
@@ -508,7 +503,7 @@ function get_sample_names(reader)
508503
end
509504

510505
"""
511-
find_group_label_indices(pheno)
506+
find_group_label_indices(pheno,trait_to_group_by,row_to_sort_by)
512507
find indices and determines names for group 1 and group 2 labels on plots. finds index of center of each sample group to place tick mark and label.
513508
"""
514509
function find_group_label_indices(pheno,trait_to_group_by,row_to_sort_by)

test/.DS_Store

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)