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

Plotting allele fraction with empty VCF raises error #73

Closed
sbslee opened this issue Oct 19, 2022 · 3 comments · Fixed by #79
Closed

Plotting allele fraction with empty VCF raises error #73

sbslee opened this issue Oct 19, 2022 · 3 comments · Fixed by #79
Labels
bug Something isn't working

Comments

@sbslee
Copy link
Owner

sbslee commented Oct 19, 2022

A user reported a potential bug in the run-ngs-pipeline command where if the user provides an empty VCF, the command will throw an error complaining the VCF is empty when it should handle this type of situations.

I haven't had a chance to reproduce the issue yet, but it's possible and likely due to

def plot_vcf_allele_fraction(

@sbslee
Copy link
Owner Author

sbslee commented Oct 22, 2022

I was able to reproduce this error using a test VCF file (I removed all variants from chr22):

(fuc) sbslee@Seung-beens-MacBook-Air test % pypgx run-ngs-pipeline \       
CYP2D6 \
grch37-CYP2D6-pipeline \
--variants grch37-variants.vcf.gz
Saved VcfFrame[Imported] to: grch37-CYP2D6-pipeline/imported-variants.zip
Saved VcfFrame[Phased] to: grch37-CYP2D6-pipeline/phased-variants.zip
Saved VcfFrame[Consolidated] to: grch37-CYP2D6-pipeline/consolidated-variants.zip
Saved SampleTable[Alleles] to: grch37-CYP2D6-pipeline/alleles.zip
Traceback (most recent call last):
  File "/Users/sbslee/opt/anaconda3/envs/fuc/bin/pypgx", line 33, in <module>
    sys.exit(load_entry_point('pypgx', 'console_scripts', 'pypgx')())
  File "/Users/sbslee/Desktop/pypgx/pypgx/__main__.py", line 33, in main
    commands[args.command].main(args)
  File "/Users/sbslee/Desktop/pypgx/pypgx/cli/run_ngs_pipeline.py", line 159, in main
    pipeline.run_ngs_pipeline(
  File "/Users/sbslee/Desktop/pypgx/pypgx/api/pipeline.py", line 252, in run_ngs_pipeline
    plot.plot_vcf_allele_fraction(
  File "/Users/sbslee/Desktop/pypgx/pypgx/api/plot.py", line 396, in plot_vcf_allele_fraction
    ax1, ax2 = _plot_vcf_allele_fraction_one(
  File "/Users/sbslee/Desktop/pypgx/pypgx/api/plot.py", line 77, in _plot_vcf_allele_fraction_one
    imported_variants.data.plot_region(sample, ax=ax2, k='#AD_FRAC_REF', label='REF')
  File "/Users/sbslee/Desktop/fuc/fuc/api/pyvcf.py", line 3203, in plot_region
    raise ValueError('VcfFrame is empty')
ValueError: VcfFrame is empty

@sbslee
Copy link
Owner Author

sbslee commented Oct 22, 2022

This error could be avoided by using the --do-not-plot-allele-fraction option, but a more permanent solution is on its way.

@sbslee
Copy link
Owner Author

sbslee commented Oct 22, 2022

This issue has been fixed in the 0.20.0-dev branch. Basically, starting with 0.20.0 if the input VCF is empty the pipeline will not attempt to plot allele fraction and instead will produce a warning. The pipeline will also notify the user how to suppress the warning:

(fuc) sbslee@Seung-beens-MacBook-Air test % pypgx run-ngs-pipeline \
CYP2D6 \
grch37-CYP2D6-pipeline \
--variants grch37-variants.vcf.gz --force
Saved VcfFrame[Imported] to: grch37-CYP2D6-pipeline/imported-variants.zip
Saved VcfFrame[Phased] to: grch37-CYP2D6-pipeline/phased-variants.zip
Saved VcfFrame[Consolidated] to: grch37-CYP2D6-pipeline/consolidated-variants.zip
Saved SampleTable[Alleles] to: grch37-CYP2D6-pipeline/alleles.zip
/Users/sbslee/Desktop/pypgx/pypgx/api/pipeline.py:257: UserWarning: Cannot plot allele fraction because input VCF is empty. Use '--do-not-plot-allele-fraction' to suppress this warning.
  warnings.warn(message)
/Users/sbslee/Desktop/pypgx/pypgx/api/genotype.py:665: UserWarning: The user did not provide CNV calls even though the target gene is known to have SV. PyPGx will assume all of the samples do not have SV.
  warnings.warn(message)
Saved SampleTable[Genotypes] to: grch37-CYP2D6-pipeline/genotypes.zip
Saved SampleTable[Phenotypes] to: grch37-CYP2D6-pipeline/phenotypes.zip
Saved SampleTable[Results] to: grch37-CYP2D6-pipeline/results.zip

sbslee added a commit that referenced this issue Oct 22, 2022
* :issue:`73`: Fix bug in :command:`run-ngs-pipeline` command where 
empty VCF (i.e. no variants were found in the target gene) was causing 
error when plotting allele fraction. From now on, a warning will be 
produced telling users to specify ``--do-not-plot-allele-fraction`` to 
suppress this warning.
@sbslee sbslee closed this as completed Oct 22, 2022
@sbslee sbslee added the bug Something isn't working label Oct 22, 2022
@sbslee sbslee linked a pull request Jan 11, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant