etal / cnvkit

Copy number variant detection from targeted DNA sequencing
http://cnvkit.readthedocs.org
Other
547 stars 165 forks source link

How to export gistic markers? #622

Closed BioComSoftware closed 3 years ago

BioComSoftware commented 3 years ago

Within export.py there's a export_gistic_markers(cnr_fnames). Also within export.py, there's a dictionary...

EXPORT_FORMATS = {
    'cdt': fmt_cdt,
    # 'gct': fmt_gct,
    'gistic': export_gistic_markers,
    'jtv': fmt_jtv,
    'nexus-basic': export_nexus_basic,
    'nexus-ogt': export_nexus_ogt,
    'seg': export_seg,
    'theta': export_theta,
    'vcf': export_vcf,
}

I've tried exporting a gistic marker file using cnvkit.py export gistic but I get an error...

# cnvkit.py export gistic
usage: cnvkit.py export [-h] {bed,seg,vcf,theta,nexus-basic,nexus-ogt,cdt,jtv} ...
cnvkit.py export: error: invalid choice: 'gistic' (choose from 'bed', 'seg', 'vcf', 'theta', 'nexus-basic', 'nexus-ogt', 'cdt', 'jtv')

What is the usage to get a gistic marker output file from cnvkit?

tetedange13 commented 3 years ago

Hi @BioComSoftware ,

Not an author of CNVkit, but reading the code I see "gistic" export is only partially implemented => The "core" part is implemented in cnvlib/export.py as you noticed => But it lacks a few lines of code within cnvlib/commands.py to allow command-line usage (this explains error you got)

Adding the following chunk of code right after L1882 of your own cnvlib/commands.py file should allow you to use "gistic" export: (as long as the "core" implementation is correct, which I could not assert)

def _cmd_export_gistic(args):
    formatter = export.EXPORT_FORMATS['gistic']
    outdf = formatter(args.filenames)
    write_dataframe(args.output, outdf)
P_export_gistic = P_export_subparsers.add_parser('gistic',
                                              help=_cmd_export_gistic.__doc__)
P_export_gistic.add_argument('filenames', nargs='+',
        help="""Log2 copy ratio data file(s) (*.cnr), the output of the
                'fix' sub-command.""")
P_export_gistic.add_argument('-o', '--output', metavar="FILENAME",
        help="Output file name.")
P_export_gistic.set_defaults(func=_cmd_export_gistic)


Hope this helps. Have a nice day. Felix.

BioComSoftware commented 3 years ago

Thanks for the fast help!

BioComSoftware commented 3 years ago

I added the above code to my copy of cnvkit, and it appears to be creating a properly formatted markers file. I will continue testing.

etal commented 3 years ago

Did the file generated by this function work properly with Gistic?

tskir commented 3 years ago

Hi @BioComSoftware, did you have a chance to test if the file is correct, so that we could merge the associated PR #623?

BioComSoftware commented 3 years ago

Hi Kirill,

I did get a chance to test it - but I'm not sure the results will be helpful.

The export did run through to completion without error, and did produce (what looks like) a properly formatted markers file.

However, when I attempted to use the markers file with GISTIC (in conjunction with the SEG file created by CNVKIT) - GISTIC failed to run and ended with errors. I was not able to confirm the errors were specifically caused by the markers file, since I managed to get GISTIC to run without a markers file at all, and stopped pursuing it.

Best, Mike

Kirill Tsukanov wrote on 6/23/2021 7:13 PM:

Hi @BioComSoftware https://github.com/BioComSoftware, did you have a chance to test if the file is correct, so that we could merge the associated PR #623 https://github.com/etal/cnvkit/pull/623?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/etal/cnvkit/issues/622#issuecomment-867015524, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABS7TXX2TTEABNEN46BLYL3TUII2HANCNFSM45YR76UQ.

-- -- Michael Rightmire B.Sci. Molecular Biotechnology MCSE, MCP+I, HPUXCA, CompTIA, VDE, SIAM, ISCB Biocom Software and Biotechnology 1-408-890-2121 (US) 49-176-7131-8758 (Handy) BiocomSoftware.com

-- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus

tetedange13 commented 3 years ago

Hi @BioComSoftware ,

Thanks for your feedback! As discussed here, for now there could be a small inconsistency between cnvkit.py export seg (used for GISTIC's -seg param) and cnvkit.py export gistic (used to feed GISTIC's -mk param) => Can you please try to remove sex-chromosomes from your SEG file, then run GISTIC again with both SEG and marker files produced by CNVkit? (your error should be gone) => Also could you instruct us about "rightfulness" of the results produced by GISTIC when fed with SEG and markers files exported with CNVkit? Do they make sense according to you?

Thanks in advance Mike. Have a nice day. Felix.