Question: How to merge multiple CNV results of CNVnator
gravatar for ChrisJ
19 months ago by
ChrisJ0 wrote:

Hello everyone: There is a problem puzzled me recently,I have got every individual CNV output by the tool of CNVnator,and next I want to merge all outputs to a file(if two CNVs have overlap >0.5 can be considered to a common one), but I don't know how to merge these files.I have tried the VCFtools( CNVnator has a perl script which can switch the out to VCF format),bcftools,bedtools ,but there is no a tool can really solve my question(some tool would discard these no-overlap CNVs),so who can give me some suggestions to solve this hard trouble? this is my output:

  # chr       start            end           type
  chr1    7967601     7984800     deletion
  chr1    9441201     9447200     duplication
  chr1    10546001   10553200    deletion
  chr1    10822001    10830400   deletion
cnv cnvnator ngs • 982 views
ADD COMMENTlink modified 19 months ago • written 19 months ago by ChrisJ0
gravatar for Pierre Lindenbaum
19 months ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum119k wrote:

a 'stupid' solution using javascript ?

// following array is generated with awk '{printf("{\"chrom\":\"%s\",\"start\":%s,\"end\":%s,\"type\":\"%s\"},\n",$1,$2,$3,$4);}' your.bed
var segments=[

var done=false;
    var i=0;
    while(done && i + 1< segments.length)
        var j = i+1;
        while(j < segments.length)
            var segi = segments[i];
            var segj = segments[j];
            if( segi.chrom != segj.chrom) {++j; continue;}
            if( segi.type != segj.type) {++j; continue;}
            if( segj.end <= segi.start)  {++j; continue;}
            if( segj.start >= segi.end)  {++j; continue;}
            var overlap_len = 1.0 * ( Math.min(segi.end,segj.end) - Math.max(segi.start,segj.start) );
            var leni =  1.0* (segi.end - segi.start);
            if( overlap_len / leni < 0.5)  {++j; continue;}
            var lenj =  1.0* (segj.end - segj.start);
            if( overlap_len / lenj < 0.5)  {++j; continue;}
                "start": Math.min(segi.start,segj.start),
                "end": Math.max(segi.end,segj.end),

for(var i in segments)
    var segi = segments[i];

invoke with jjs or in a firefox scratchad

$ jjs script.js
chr1    7967601 7984810 duplication
chr1    7967602 7967603 duplication
chr1    1   100 duplication
chr1    10546001    10553200    deletion
ADD COMMENTlink written 19 months ago by Pierre Lindenbaum119k
gravatar for ChrisJ
19 months ago by
ChrisJ0 wrote:

ok,thank you very much .and I will try it .

ADD COMMENTlink written 19 months ago by ChrisJ0
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 888 users visited in the last hour