No announcement yet.

CNVkit: Copy number detection and visualization for targeted sequencing using off-tar

  • Filter
  • Time
  • Show
Clear All
new posts

  • CNVkit: Copy number detection and visualization for targeted sequencing using off-tar

    CNVkit is a software toolkit to infer and visualize copy number from targeted DNA sequencing data. It is designed for use with hybrid capture, including both whole-exome and custom target panels, and short-read sequencing platforms such as Illumina.

    This method uses the nonspecifically captured off-target reads to supplement read depth information from on-target regions. With relatively simple normalization steps to make these read depths comparable across the genome, CNVkit can produce copy ratio estimates extremely close to those by array CGH.

    Manuscript preprint:

    Source code:


    I've attempted to make CNVkit compatible with other software and easy to integrate into sequencing analysis pipelines. (Currently supported or under development: bcbio-nextgen, Galaxy, THetA2, IGV, BioDiscovery Nexus Copy Number, Java TreeView, probably others.) If you would like to see CNVkit play nicely with another existing program, please let me know.
    Last edited by etal; 02-04-2015, 09:41 AM.

  • #2
    Hi etal,

    As I am not fluent with python (and certainly not my collagues), I wondered what progress you made with running in Galaxy (is there already a toolshed-version?) and/or the combination with Biodiscovery's Nexus. Would the latter be a report in a txt-format readable by Nexus?

    With regards, Jasper


    • #3
      Hi Jasper,

      If you would like to quickly get started without doing any technical work, I recommend the DNAnexus app, which is essentially complete and free to use initially after you've set up a DNAnexus account.

      The Galaxy tool is not feature-complete, but I've made it available for testing in the Test Tool Shed (not the production one) in order to learn how people would like to use it. I'll spend more time on this if there's interest, but at the moment it's not the easiest way to use CNVkit.

      The BioDiscovery Nexus Copy Number support in CNVkit is simple: CNVkit can export bin-level log2 copy ratio data to a tabular file which can then be loaded in Nexus Copy Number (e.g. " export nexus-basic MySample.cnr -o"). The DNAnexus applet also emits these files. Then, within Nexus Copy Number, load the generated file and specify the "basic" format. The copy number data should then appear similarly to array CGH.

      Also, please note that CNVkit does not require Python programming to use, only the Unix/Linux command line. Feel free to let me know if you find any of the commands difficult to use or poorly documented.
      Last edited by etal; 02-04-2015, 09:40 AM.


      • #4
        Hi Etal,

        For the moment it appears that using a Galaxy is the better solution for us. I am running one in a VMware and installed CNVkit this morning. Now I am uploading some .bam files to work with.

        With regards, Jasper


        • #5
          Hi Etal,

          In the current galaxy wrapper all three .bam files appear in both the 'sample' list, as well the 'Normal' list, without a selection or adjustment option.


          • #6
            The BAM files available on your server or under your account (however you've set it up) should be visible under either field in the input form, and you should be able to select the files you want for each field through the usual means, e.g. Ctrl+click. Choose the tumor samples for the "sample" list, and any normal or germline files that were sequenced under the same protocol for the "normal" list.

            You can also run it without any "normal" BAM inputs and the results should be reasonably good.


            • #7
              Hi etal, I have a more basic question for CNV detection- If I have a custom target panel through Ampliseq multiplex PCR, then is there a way to detect CNVs in that data?

              Your CNVkit software works only for hybrid capture target panels like TSCA (Illumina) and Haloplex (Agilent)? Am I getting it correct?



              • #8
                Yes, CNVkit is designed for hybrid capture target panels like those of Illumina, Agilent and Nimblegen. For best results from amplicon-based targeted resequencing, you should probably use another program like OncoCNV.

                I've recently added a little bit of support for running the CNVkit pipeline without using any off-target bins. You can try it by downloading release 0.3.4 and following the instructions here. However, this new feature isn't thoroughly tested and I'm told it doesn't work for everyone, and in any case another layer of gene-level normalizations would be needed to make it perform well on targeted amplicon sequencing data. I'll let SeqAnswers know when that mode is ready for broader use.
                Last edited by etal; 02-23-2015, 09:58 PM.


                • #9
                  Thanks etal for your reply and this information. I will look into OncoCNV.


                  • #10
                    fail to open file?

                    Hi Etal,

                    I wanted to test CNVkit on a small set of targeted sequencing data, but it is giving me trouble. With both batch and coverage (I haven't tried the other functions yet), I get the error:

                    "Processing reads in test.bam
                    [E::hts_open] fail to open file '-Q'
                    Segmentation fault: 11"

                    The indexing right before this worked fine. The chromosome names in my bam-files, fasta and target files are all the same (no "chr" prefix). The tests of cnvkit were all ok, no errors or warnings, and my pysam and pyvcf are up to date.
                    Any idea what I can do to fix this?

                    Thanks in advance,


                    • #11
                      Hi Marlous,

                      Thanks for reporting this. Can you show me the commands you used to trigger this error, including any special options you used? Are your BAM files definitely in BAM format, and e.g. "samtools idxstats" works on your BAM files?

                      I think this error indicates that command line options for "samtools bedcov" on your system are different than those in the versions I tested, missing the "-Q" option to set a minimum mapping quality score when counting reads. This would break CNVkit's coverage command internally. The source code of pysam's bundled samtools (in both pysam 0.8.0 and the current trunk) shows that the bedcov command does still accept the -Q option (using getopt), so either you have a version of pysam/samtools/htslib different from what I looked at, or I'm misunderstanding the error. The bedcov command is barely documented in samtools 1.1 and I can't see why this option might be missing in some versions. Maybe a samtools expert here can help?

                      In the meantime, you can avoid the call to bedcov with " coverage --count", which returns similar results to the default strategy but filters out unmapped reads directly using the Pysam API, rather than by calling bedcov with the -Q option.

                      Last edited by etal; 02-25-2015, 11:28 PM. Reason: Inspected the current pysam/samtools source code.


                      • #12
                        Hey Eric,

                        Thanks for the quick reply! My bam-files are indeed bam-files, the idxstats works fine. I tried samtools bedcov from the command line (version 1.2), without the '-Q' option it works fine but if I add this option I get the same error message, so it seems to be a samtools-related error indeed...
                        I was mostly interested in the batch option from CNVkit, is it also possible to run this while circumventing the -Q?

                        Just to be sure, the command I used for the coverage analysis:
                        python coverage ~/Documents/CNVkit/testT_dedup.realigned.bam ~/Documents/genomes/design_test4.bed -o ~/Documents/CNVkit/test_dedup.realigned.cnn
                        Processing reads in testT_dedup.realigned.bam
                        [E::hts_open] fail to open file '-Q'
                        Segmentation fault: 11
                        For the batch analysis:
                        python batch ~/Documents/CNVkit/*T_dedup.realigned.bam --normal ~/Documents/CNVkit/*R*bam --fasta ~/Documents/genomes/GRCh37_gatk.fasta --access ~/bin/cnvkit/data/access-10kb.hg19_noChr.bed --output-reference ~/Documents/CNVkit/test.cnn --output-dir ~/Documents/test/ -t ~/Documents/genomes/design_test4.bed
                        Detected file format: BED
                        Detected file format: BED
                        Detected file format: BED
                        Wrote /Users/.../Documents/CNVkit/test/design_test4.antitarget.bed with 1678 background intervals
                        Building a copy number reference from normal samples...
                        Processing reads in test1R_dedup.realigned.bam
                        [E::hts_open] fail to open file '-Q'
                        Segmentation fault: 11
                        Thanks again, Marlous


                        • #13
                          I've added the "-c/--count" option from the "coverage" command to the "batch" options as well. If you installed CNVkit from the GitHub repo, you can get the latest by either pulling the new commits or downloading the latest source code Zip file from the master branch and installing that.

                          Please let me know if that works for you.


                          • #14
                            Works like a charm, thank you so much.

                            Also, very pleased with the results!
                            Last edited by Mulos; 02-27-2015, 07:25 AM.


                            • #15
                              HI Etal,

                              Very nice work on a promising tool.

                              I'm giving it a go as well and what strikes me is that I don't always get the PDF files with the diagram and scatter option in a batch run. Is there a way to get verbose (error) logging?

                              When I do generate them with the individual scatter/diagram option, they are there, but the diagram is very difficult to read as all the labels overlap each other. Is there a way to influence this, or break all chromosomes to sepperate pages?

                              If i'm on a X11 terminal I can generate the plots, but when we run analyses on the cluster, there is no display available and we would need the pdf files.

                              Additionally, it would be great if you could use both sample.bam.bai als sample.bai file as indices.

                              Best, Ies
                              ps: and Hi to all the other posters!
                              Last edited by inijman; 03-02-2015, 03:42 AM.