Skip to content

Commit

Permalink
docs(AddExamplesSectionToDocs): added complete examples with embedded…
Browse files Browse the repository at this point in the history
… html graphics for easy introduction to viva use
  • Loading branch information
gtollefson committed Apr 4, 2019
1 parent 85a640a commit 2b44a0c
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 25 deletions.
42 changes: 34 additions & 8 deletions docs/src/examples.md
Original file line number Diff line number Diff line change
@@ -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)

```
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)

6 changes: 3 additions & 3 deletions src/plot_utils.jl
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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)
)
Expand Down Expand Up @@ -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",
Expand Down
28 changes: 14 additions & 14 deletions src/vcf_utils_complete.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Binary file modified test/.DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions viva
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.")

Expand Down

0 comments on commit 2b44a0c

Please sign in to comment.