diff --git a/docs/src/examples.md b/docs/src/examples.md index 7d7f6fd..c6240eb 100644 --- a/docs/src/examples.md +++ b/docs/src/examples.md @@ -1,20 +1,46 @@ # Examples +To run examples, download the five test files found [here](https://github.com/compbiocore/VariantVisualization.jl/tree/master/test/test_files) and put them into a working directory with the VIVA script. + +Once Julia and VariantVisualization.jl are installed, you can run the following examples and should see the same outputs. + ## Default Options Running VIVA with no options produces heatmaps of genotype and read depth values for all samples and variant positions in the VCF file with default options. You can read about VIVA's default settings [here](https://compbiocore.github.io/VariantVisualization.jl/stable/#default-options) -![Default Genotype Heatmap](assets/VIVA_logo.png) -![Default Read Depth Heatmap](assets/VIVA_logo.png) +``` +julia VIVA -f test_4X_191.vcf -t Default_Options +``` + +![Default Genotype Heatmap](assets/Genotype_Default_Options.html) +![Default Read Depth Heatmap](assets/Read_Depth_Default_Options.html) -## Generate All VIVA Plots While Grouping Samples by Metadata Traits +## Grouping Samples by Metadata Traits and Generating all Four Plots Group samples by sequencing facility and generate heatmaps of genotype and read depth values as well as scatter plots of average read depth for both all selected samples and all selected variant positions. You can find grouping options [here]([options](https://compbiocore.github.io/VariantVisualization.jl/stable/filtering_vcf/#selecting-and-grouping-samples) to group samples by common traits.) -![Grouped Genotype Heatmap](assets/VIVA_logo.png) -![Grouped Read Depth Heatmap](assets/VIVA_logo.png) -![Grouped Variant Average Read Depth Scatter Plot](assets/VIVA_logo.png) -![Grouped Sample Average Read Depth Scatter Plot](assets/VIVA_logo.png) - \ No newline at end of file +``` +julia VIVA -f test_4X_191.vcf -t Grouped_by_Sequencing_Site -g sample_metadata_matrix.csv seq_site_1,seq_site_2 --avg_dp variant,sample +``` + +![Grouped Genotype Heatmap](assets/Read_Depth_Grouped_by_Sequencing_Site.html) + +![Grouped Read Depth Heatmap](assets/Genotype_Grouped_by_Sequencing_Site.html) + +![Grouped Variant Average Read Depth Scatter Plot](assets/Average_Variant_Read_Depthtest_4X_191.vcf.html) + +![Grouped Sample Average Read Depth Scatter Plot](assets/Average_Sample_Read_Depth_test_4X_191.vcf.html) + +##Genomic Range and Samples Selection - Genotype and Read Depth Heatmaps with Variant Position Labels + +Generate heatmaps of genotype and read depth values of variants selected within a genomic range, in this case, chromosome 4, nucleotides 200000-500000, with y-axis variant position labels. + +``` +julia VIVA -f test/test_files/test_4X_191.vcf -t Genomic_Range_Chr4:3076150-3076390 -r chr4:3076150-3076390 -y positions --select_samples select_samples_list.txt +``` + +![Genomic Range Genotype Heatmap](assets/Genotype_Genomic_Range_Chr4/3076150-3076390.html) +![Genomic Range Read Depth Heatmap](assets/Read_Depth_Genomic_Range_Chr4/3076150-3076390.html) + diff --git a/src/plot_utils.jl b/src/plot_utils.jl index baec34d..9d1bf4e 100644 --- a/src/plot_utils.jl +++ b/src/plot_utils.jl @@ -1,7 +1,7 @@ #heatmap plots for grouped and ungrouped genotype and read depth viz """ - genotype_heatmap2(input::Array{Any,2},title::AbstractString,filename,sample_names,gt_chromosome_labels,y_axis_label_option,x_axis_label_option,save_ext,chrom_label_info) + genotype_heatmap2(input::Array{Any,2},title::AbstractString,filename,sample_names,gt_chromosome_labels,y_axis_label_option,x_axis_label_option) generate heatmap of genotype data. """ function genotype_heatmap2(input,title,chrom_label_info,sample_names,chr_pos_tuple_list_rev,y_axis_label_option,x_axis_label_option) #chr_pos_tuple_list_rev is rev because heatmap in plotly mirrors list for some reason. @@ -36,7 +36,7 @@ function genotype_heatmap2(input,title,chrom_label_info,sample_names,chr_pos_tup layout = Layout( title = "$title_no_underscores", xaxis=attr(title="Sample ID", showgrid=false, zeroline=false, tickvals=sample_name_indices, - ticktext=sample_names, tickfont_size=5, tickangle=45,showticklabels=x_axis_label_option), + ticktext=sample_names, tickfont_size=5, tickangle=45,showticklabels=true), yaxis=attr(title="Genomic Location", zeroline=false, tickvals=chrom_label_indices, ticktext=chrom_labels,tickfont_size=font_size,hovermode=true,automargin=true) ) @@ -365,7 +365,7 @@ function dp_heatmap2_with_groups(input::Array{Int64,2},title::String,chrom_label [0.5625, "rgb(43,124,255)"], [1, "rgb(0,64,168)"] ], - + colorbar = attr(tickvals = [-60, -40, -20, 0, 20, 40, 60, 80, 99], title="Depth / Trait", diff --git a/src/vcf_utils_complete.jl b/src/vcf_utils_complete.jl index 5ad5518..8f11014 100644 --- a/src/vcf_utils_complete.jl +++ b/src/vcf_utils_complete.jl @@ -145,7 +145,7 @@ function io_genomic_range_vcf_filter(chr_range::String,vcf_filename::AbstractStr while !eof(reader) read!(reader, vcf_record) - if (VCF.chrom(vcf_record) == chrwhole) && (chr_range_high > VCF.pos(vcf_record) > chr_range_low) + if (VCF.chrom(vcf_record) == chrwhole) && (chr_range_high >= VCF.pos(vcf_record) >= chr_range_low) push!(vcf_subarray,copy(vcf_record)) end end @@ -154,7 +154,7 @@ function io_genomic_range_vcf_filter(chr_range::String,vcf_filename::AbstractStr while !eof(reader) read!(reader, vcf_record) - if (VCF.chrom(vcf_record) == chr) && (chr_range_high > VCF.pos(vcf_record) > chr_range_low) + if (VCF.chrom(vcf_record) == chr) && (chr_range_high >= VCF.pos(vcf_record) >= chr_range_low) push!(vcf_subarray,copy(vcf_record)) end end @@ -303,14 +303,14 @@ function pass_genomic_range_siglist_filter(vcf_filename,sig_list,chr_range::Abst #if occursin("chr",VCF.chrom(record1))#version if occursin("chr",VCF.chrom(record1)) - if (VCF.chrom(vcf_record) == chr_sig) && (VCF.pos(vcf_record) == pos_sig) && (VCF.hasfilter(vcf_record)) && (VCF.filter(vcf_record) == String["PASS"]) && ((VCF.chrom(vcf_record) == chrwhole)) && ((chr_range_high > VCF.pos(vcf_record) > chr_range_low)) + if (VCF.chrom(vcf_record) == chr_sig) && (VCF.pos(vcf_record) == pos_sig) && (VCF.hasfilter(vcf_record)) && (VCF.filter(vcf_record) == String["PASS"]) && ((VCF.chrom(vcf_record) == chrwhole)) && ((chr_range_high >= VCF.pos(vcf_record) >= chr_range_low)) push!(vcf_subarray,copy(vcf_record)) break end else - if (VCF.chrom(vcf_record) == chr_sig) && (VCF.pos(vcf_record) == pos_sig) && (VCF.hasfilter(vcf_record)) && (VCF.filter(vcf_record) == String["PASS"]) && ((VCF.chrom(vcf_record) == chr)) && ((chr_range_high > VCF.pos(vcf_record) > chr_range_low)) + if (VCF.chrom(vcf_record) == chr_sig) && (VCF.pos(vcf_record) == pos_sig) && (VCF.hasfilter(vcf_record)) && (VCF.filter(vcf_record) == String["PASS"]) && ((VCF.chrom(vcf_record) == chr)) && ((chr_range_high >= VCF.pos(vcf_record) >= chr_range_low)) push!(vcf_subarray,copy(vcf_record)) break end @@ -320,13 +320,13 @@ function pass_genomic_range_siglist_filter(vcf_filename,sig_list,chr_range::Abst if occursin("chr",VCF.chrom(record1)) - if (VCF.chrom(vcf_record) == chr_sig) && (VCF.pos(vcf_record) == pos_sig) && (VCF.hasfilter(vcf_record)) && (VCF.filter(vcf_record) == String["PASS"]) && ((VCF.chrom(vcf_record) == chrwhole)) && ((chr_range_high > VCF.pos(vcf_record) > chr_range_low)) + if (VCF.chrom(vcf_record) == chr_sig) && (VCF.pos(vcf_record) == pos_sig) && (VCF.hasfilter(vcf_record)) && (VCF.filter(vcf_record) == String["PASS"]) && ((VCF.chrom(vcf_record) == chrwhole)) && ((chr_range_high >= VCF.pos(vcf_record) >= chr_range_low)) push!(vcf_subarray,copy(vcf_record)) break end else - if (VCF.chrom(vcf_record) == chr_sig) && (VCF.pos(vcf_record) == pos_sig) && (VCF.hasfilter(vcf_record)) && (VCF.filter(vcf_record) == String["PASS"]) && ((VCF.chrom(vcf_record) == chr)) && ((chr_range_high > VCF.pos(vcf_record) > chr_range_low)) + if (VCF.chrom(vcf_record) == chr_sig) && (VCF.pos(vcf_record) == pos_sig) && (VCF.hasfilter(vcf_record)) && (VCF.filter(vcf_record) == String["PASS"]) && ((VCF.chrom(vcf_record) == chr)) && ((chr_range_high >= VCF.pos(vcf_record) >= chr_range_low)) push!(vcf_subarray,copy(vcf_record)) break end @@ -376,14 +376,14 @@ returns subarray of vcf records with io_pass_filter and io_genomic_range_vcf_fil chr = string(chr) - if (VCF.hasfilter(vcf_record)) && (VCF.filter(vcf_record) == String["PASS"]) && ((VCF.chrom(vcf_record) == chrwhole)) && ((chr_range_high > VCF.pos(vcf_record) > chr_range_low)) + if (VCF.hasfilter(vcf_record)) && (VCF.filter(vcf_record) == String["PASS"]) && ((VCF.chrom(vcf_record) == chrwhole)) && ((chr_range_high >= VCF.pos(vcf_record) >= chr_range_low)) push!(vcf_subarray,copy(vcf_record)) end else - if (VCF.hasfilter(vcf_record)) && (VCF.filter(vcf_record) == String["PASS"]) && ((VCF.chrom(vcf_record) == chrwhole)) && ((chr_range_high > VCF.pos(vcf_record) > chr_range_low)) + if (VCF.hasfilter(vcf_record)) && (VCF.filter(vcf_record) == String["PASS"]) && ((VCF.chrom(vcf_record) == chrwhole)) && ((chr_range_high >= VCF.pos(vcf_record) >= chr_range_low)) push!(vcf_subarray,copy(vcf_record)) end end @@ -394,13 +394,13 @@ returns subarray of vcf records with io_pass_filter and io_genomic_range_vcf_fil if typeof(VCF.chrom(vcf_record)) == String chr = string(chr) - if (VCF.hasfilter(vcf_record)) && (VCF.filter(vcf_record) == String["PASS"]) && ((VCF.chrom(vcf_record) == chr)) && ((chr_range_high > VCF.pos(vcf_record) > chr_range_low)) + if (VCF.hasfilter(vcf_record)) && (VCF.filter(vcf_record) == String["PASS"]) && ((VCF.chrom(vcf_record) == chr)) && ((chr_range_high >= VCF.pos(vcf_record) >= chr_range_low)) push!(vcf_subarray,copy(vcf_record)) end else - if (VCF.hasfilter(vcf_record)) && (VCF.filter(vcf_record) == String["PASS"]) && ((VCF.chrom(vcf_record) == chr)) && ((chr_range_high > VCF.pos(vcf_record) > chr_range_low)) + if (VCF.hasfilter(vcf_record)) && (VCF.filter(vcf_record) == String["PASS"]) && ((VCF.chrom(vcf_record) == chr)) && ((chr_range_high >= VCF.pos(vcf_record) >= chr_range_low)) push!(vcf_subarray,copy(vcf_record)) end @@ -505,14 +505,14 @@ function genomic_range_siglist_filter(vcf_filename,sig_list,chr_range::AbstractS if typeof(VCF.chrom(vcf_record)) == String chr_sig = string(chr_sig) - if (VCF.chrom(vcf_record) == chr_sig) && (VCF.pos(vcf_record) == pos_sig) && ((VCF.chrom(vcf_record) == chrwhole)) && ((chr_range_high > VCF.pos(vcf_record) > chr_range_low)) + if (VCF.chrom(vcf_record) == chr_sig) && (VCF.pos(vcf_record) == pos_sig) && ((VCF.chrom(vcf_record) == chrwhole)) && ((chr_range_high >= VCF.pos(vcf_record) >= chr_range_low)) push!(vcf_subarray,copy(vcf_record)) break end else - if (VCF.chrom(vcf_record) == chr_sig) && (VCF.pos(vcf_record) == pos_sig) && ((VCF.chrom(vcf_record) == chrwhole)) && ((chr_range_high > VCF.pos(vcf_record) > chr_range_low)) + if (VCF.chrom(vcf_record) == chr_sig) && (VCF.pos(vcf_record) == pos_sig) && ((VCF.chrom(vcf_record) == chrwhole)) && ((chr_range_high >= VCF.pos(vcf_record) >= chr_range_low)) push!(vcf_subarray,copy(vcf_record)) break end @@ -523,14 +523,14 @@ function genomic_range_siglist_filter(vcf_filename,sig_list,chr_range::AbstractS if typeof(VCF.chrom(vcf_record)) == String chr_sig = string(chr_sig) - if (VCF.chrom(vcf_record) == chr_sig) && (VCF.pos(vcf_record) == pos_sig) && ((VCF.chrom(vcf_record) == chr)) && ((chr_range_high > VCF.pos(vcf_record) > chr_range_low)) + if (VCF.chrom(vcf_record) == chr_sig) && (VCF.pos(vcf_record) == pos_sig) && ((VCF.chrom(vcf_record) == chr)) && ((chr_range_high >= VCF.pos(vcf_record) >= chr_range_low)) push!(vcf_subarray,copy(vcf_record)) break end else - if (VCF.chrom(vcf_record) == chr_sig) && (VCF.pos(vcf_record) == pos_sig) && ((VCF.chrom(vcf_record) == chr)) && ((chr_range_high > VCF.pos(vcf_record) > chr_range_low)) + if (VCF.chrom(vcf_record) == chr_sig) && (VCF.pos(vcf_record) == pos_sig) && ((VCF.chrom(vcf_record) == chr)) && ((chr_range_high >= VCF.pos(vcf_record) >= chr_range_low)) push!(vcf_subarray,copy(vcf_record)) break end diff --git a/test/.DS_Store b/test/.DS_Store index 2769642..41f5603 100644 Binary files a/test/.DS_Store and b/test/.DS_Store differ diff --git a/viva b/viva index 6aa7930..c2aedf8 100755 --- a/viva +++ b/viva @@ -163,6 +163,7 @@ end =# if parsed_args["x_axis_labels"] == true + println("test2N") x_axis_label_option = true else x_axis_label_option = false @@ -440,6 +441,8 @@ if parsed_args["heatmap"] == "genotype,read_depth" || parsed_args["heatmap"] == gt_num_array,col_selectedcolumns = select_columns(parsed_args["select_samples"], gt_num_array, sample_names) sample_names=col_selectedcolumns + println(sample_names) + elseif parsed_args["select_samples"] != nothing && length(parsed_args["group_samples"]) == 2 println("Can not select samples with phenotype matrix provided. Please include same sample ids in phenotype matrix as in list of sample names to select.")