How to merge multiple CNV results of CNVnator
2
0
Entering edit mode
6.6 years ago
ChrisJ • 0

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
NGS CNV CNVnator • 2.8k views
ADD COMMENT
0
Entering edit mode

I met the same problem. Have you solve it?

ADD REPLY
0
Entering edit mode

hi, I also met the same problem ...

ADD REPLY
0
Entering edit mode
6.6 years ago

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=[
{"chrom":"chr1","start":7967601,"end":7984800,"type":"duplication"},
{"chrom":"chr1","start":7967602,"end":7984810,"type":"duplication"},
{"chrom":"chr1","start":7967602,"end":7967603,"type":"duplication"},
{"chrom":"chr1","start":1,"end":100,"type":"duplication"},
{"chrom":"chr1","start":10546001,"end":10553200,"type":"deletion"},
{"chrom":"chr1","start":10546101,"end":10553000,"type":"deletion"}
]

var done=false;
while(done==false)
    {
    done=true;
    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;}
            segments.splice(j,1);
            segments[i]={
                "chrom":segi.chrom,
                "start": Math.min(segi.start,segj.start),
                "end": Math.max(segi.end,segj.end),
                "type":segi.type
                }
            done=false;
            }
        i++;
        }
    }

for(var i in segments)
    {
    var segi = segments[i];
    print(segi.chrom+"\t"+segi.start+"\t"+segi.end+"\t"+segi.type);
    }

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 COMMENT
0
Entering edit mode
6.6 years ago
ChrisJ • 0

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

ADD COMMENT

Login before adding your answer.

Traffic: 1957 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6