Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finished most tests. Fixed siglist filter functions. #8

Merged
merged 6 commits into from
Nov 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
*.html
.DS_Store
.ipynb_checkpoints/
output
39 changes: 21 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
## Documentation: http://docs.travis-ci.com/user/languages/julia/
language: julia

# os:
# - linux
# - osx
#
# julia:
# - 0.6
#
# notifications:
# email: false
#
# git:
# depth: 99999999
#
# before_script:
# - export PATH=$HOME/.local/bin:$PATH
os:
- linux
- osx

# after_success:
# - julia -e 'import Pkg; Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
julia:
- 0.6

notifications:
email: false

git:
depth: 99999999

before_script:
- export PATH=$HOME/.local/bin:$PATH

script:
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
- 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)'

after_success:
- julia -e 'Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'

jobs:
include:
Expand Down
15 changes: 0 additions & 15 deletions ViVa_v2.jl

This file was deleted.

2 changes: 0 additions & 2 deletions open_jupyter_notebook.jl

This file was deleted.

10 changes: 5 additions & 5 deletions src/ViVa.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module ViVa

using DataFrames #use CSV.jl ? depwarnings
using DataFrames
using PlotlyJS
using Rsvg
using Blink
using CSV
using GeneticVariation
using ArgParse
using VCFTools
#using VCFTools
#using Base.Filesystem



Expand Down Expand Up @@ -42,9 +42,9 @@ export
avg_variant_dp_line_chart,
read_depth_threshhold,
list_variant_positions_low_dp,
list_sample_positions_low_dp,
list_sample_names_low_dp,
avg_dp_variant,
avg_dp_patients,
avg_dp_samples,
jupyter_main,
save_numerical_array,
io_pass_filter,
Expand Down
8 changes: 4 additions & 4 deletions src/plot_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ function genotype_heatmap2(input,title,chrom_label_info,sample_names)
end

"""
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)
generate heatmap of genotype data.
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)
generate heatmap of genotype data.
"""
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)

Expand Down Expand Up @@ -127,7 +127,7 @@ function dp_heatmap2(input, title, chrom_label_info, sample_names)
end

"""
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})
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})
generate heatmap of read depth data with grouped samples.
"""
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})
Expand Down Expand Up @@ -174,7 +174,7 @@ function dp_heatmap2_with_groups(input::Array{Int64,2},title::String,chrom_label
end

"""
avg_sample_dp_scatter(sample_avg_list::Array{Float64,1},sample_names)
avg_sample_dp_scatter(sample_avg_list::Array{Float64,1},sample_names)
generate line chart of average read depths of each sample.
"""
function avg_sample_dp_scatter(sample_avg_list::Array{Float64,1},sample_names)
Expand Down
143 changes: 69 additions & 74 deletions src/vcf_utils_complete.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ function sort_genotype_array(genotype_array)
data=genotype_array[:,3:size(genotype_array,2)]
chrom_positions = [parse(Int, i) for i in genotype_array[:,1:2]]
genotype_array = hcat(chrom_positions,data)

genotype_array = sortrows(genotype_array, by=x->(x[1],x[2]))

return genotype_array
Expand Down Expand Up @@ -111,38 +110,37 @@ end
io_sig_list_vcf_filter(sig_list,vcf_filename)
returns subarray of variant records matching a list of variant positions returned from load_siglist()
"""
function io_sig_list_vcf_filter(sig_list,vcf_filename)

vcf_subarray = Array{Any}(0)
function io_sig_list_vcf_filter(sig_list,vcf_filename)

for row= 1:size(sig_list,1)
dimension = size(sig_list,1)
reader = VCF.Reader(open(vcf_filename, "r"))

chr=(sig_list[row,1])
pos=(sig_list[row,2])
vcf_subarray = Array{Any}(0)

reader = VCF.Reader(open(vcf_filename, "r"))
for record in reader

for record in reader
for row= 1:size(sig_list,1)
dimension = size(sig_list,1)

if typeof(VCF.chrom(record)) == String
chr = string(chr)
chr=(sig_list[row,1])
pos=(sig_list[row,2])

if (VCF.chrom(record) == chr) && (VCF.pos(record) == pos)
push!(vcf_subarray,record)
end
if typeof(VCF.chrom(record)) == String
chr = string(chr)
if (VCF.chrom(record) == chr) && (VCF.pos(record) == pos)
push!(vcf_subarray,record)
end

else
else

if (VCF.chrom(record) == chr) && (VCF.pos(record) == pos)
push!(vcf_subarray,record)
if (VCF.chrom(record) == chr) && (VCF.pos(record) == pos)
push!(vcf_subarray,record)

end
end
end
end
end
end
end

return vcf_subarray
return vcf_subarray
end

"""
Expand Down Expand Up @@ -183,16 +181,16 @@ function pass_chrrange_siglist_filter(vcf_filename,sig_list,chr_range::AbstractS

vcf_subarray = Array{Any}(0)

for row= 1:size(sig_list,1)
reader = VCF.Reader(open(vcf_filename, "r"))

for record in reader

for row = 1:size(sig_list,1)
dimension = size(sig_list,1)

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

reader = VCF.Reader(open(vcf_filename, "r"))

for record in reader

if typeof(VCF.chrom(record)) == String
chr = string(chr)

Expand Down Expand Up @@ -255,23 +253,23 @@ returns subarray of vcf records with io_pass_filter and io_chromosome_range_vcf_
end

"""
pass_siglist_filter(vcf_filename,sig_list,chr_range::AbstractString)
returns subarray of vcf records with io_pass_filter, io_sig_list_vcf_filter, and io_chromosome_range_vcf_filter applied.
pass_siglist_filter(vcf_filename,sig_list,chr_range::AbstractString)
returns subarray of vcf records with io_pass_filter, io_sig_list_vcf_filter, and io_chromosome_range_vcf_filter applied.
"""
function pass_siglist_filter(vcf_filename,sig_list)
function pass_siglist_filter(vcf_filename,sig_list)

vcf_subarray = Array{Any}(0)
vcf_subarray = Array{Any}(0)

reader = VCF.Reader(open(vcf_filename, "r"))

for record in reader

for row= 1:size(sig_list,1)
dimension = size(sig_list,1)

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

reader = VCF.Reader(open(vcf_filename, "r"))

for record in reader

if typeof(VCF.chrom(record)) == String
chr = string(chr)

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

if (VCF.chrom(record) == chr) && (VCF.pos(record) == pos) && (VCF.hasfilter(record)) && (VCF.filter(record) == String["PASS"])
push!(vcf_subarray,record)

end
end
end
end
end

return vcf_subarray
end
return vcf_subarray
end

"""
chrrange_siglist_filter(vcf_filename,sig_list,chr_range::AbstractString)
returns subarray of vcf records with io_pass_filter, io_sig_list_vcf_filter, and io_chromosome_range_vcf_filter applied.
"""
function chrrange_siglist_filter(vcf_filename,sig_list,chr_range::AbstractString)
function chrrange_siglist_filter(vcf_filename,sig_list,chr_range::AbstractString)

a=split(chr_range,":")
chrwhole=a[1]
chrnumber=split(chrwhole,"r")
string_chr=chrnumber[2]
chr=String(string_chr)
range=a[2]
splitrange=split(range, "-")
lower_limit=splitrange[1]
chr_range_low=parse(lower_limit)
upper_limit=splitrange[2]
chr_range_high=parse(upper_limit)
a=split(chr_range,":")
chrwhole=a[1]
chrnumber=split(chrwhole,"r")
string_chr=chrnumber[2]
chr=String(string_chr)
range=a[2]
splitrange=split(range, "-")
lower_limit=splitrange[1]
chr_range_low=parse(lower_limit)
upper_limit=splitrange[2]
chr_range_high=parse(upper_limit)

vcf_subarray = Array{Any}(0)
vcf_subarray = Array{Any}(0)

for row= 1:size(sig_list,1)
dimension = size(sig_list,1)
reader = VCF.Reader(open(vcf_filename, "r"))

chr=(sig_list[row,1])
pos=(sig_list[row,2])
for record in reader

reader = VCF.Reader(open(vcf_filename, "r"))
for row= 1:size(sig_list,1)
dimension = size(sig_list,1)

for record in reader
chr=(sig_list[row,1])
pos=(sig_list[row,2])

if typeof(VCF.chrom(record)) == String
chr = string(chr)
if typeof(VCF.chrom(record)) == String
chr = string(chr)

if (VCF.chrom(record) == chr) && (VCF.pos(record) == pos) && ((VCF.chrom(record) == chr)) && ((chr_range_high > VCF.pos(record) > chr_range_low))
push!(vcf_subarray,record)
end
if (VCF.chrom(record) == chr) && (VCF.pos(record) == pos) && ((VCF.chrom(record) == chr)) && ((chr_range_high > VCF.pos(record) > chr_range_low))
push!(vcf_subarray,record)
end

else
else

if (VCF.chrom(record) == chr) && (VCF.pos(record) == pos) && ((VCF.chrom(record) == chr)) && ((chr_range_high > VCF.pos(record) > chr_range_low))
push!(vcf_subarray,record)
if (VCF.chrom(record) == chr) && (VCF.pos(record) == pos) && ((VCF.chrom(record) == chr)) && ((chr_range_high > VCF.pos(record) > chr_range_low))
push!(vcf_subarray,record)

end
end
end
end
end
end
end

return vcf_subarray
end
return vcf_subarray
end

#functions for converting vcf record array to numerical array

Expand All @@ -367,9 +364,7 @@ convert sub from variant filters to gt_num_array and gt_chromosome_labels for pl
"""
function combined_all_genotype_array_functions(sub)
genotype_array = generate_genotype_array(sub,"GT")

map!(s->replace(s, "chr", ""), genotype_array, genotype_array)

clean_column1!(genotype_array)
genotype_array=ViVa.sort_genotype_array(genotype_array)
geno_dict = define_geno_dict()
Expand Down Expand Up @@ -508,7 +503,7 @@ function get_sample_names(reader)
end

"""
find_group_label_indices(pheno)
find_group_label_indices(pheno,trait_to_group_by,row_to_sort_by)
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.
"""
function find_group_label_indices(pheno,trait_to_group_by,row_to_sort_by)
Expand Down
Binary file modified test/.DS_Store
Binary file not shown.
Loading