Combine multiple count matrices in R -


i have 5 matrices 3 common columns , more 400k rows. each column has chromosome, genomic position , read counts per position. however, each matrix has different number of rows.

> head(sm1counts)           chromosome position sm1x 27275 nw_017614756.1    17486 5425 3568     nc_013663.1     2626 4173 9087     nc_013663.1     5935 4153 9546     nc_013663.1     6223 3830 8094     nc_013663.1     5346 3491 27569 nw_017614756.1    17749 3388  > head(bm1counts)           chromosome position bm1x 8630     nc_013663.1     5935 3656 3414     nc_013663.1     2626 3449 7728     nc_013663.1     5346 3333 9093     nc_013663.1     6223 3163 3132     nc_013663.1     2445 2670 25920 nw_017614756.1    17486 2625 

as can see above, there rows between matrices contain same information different counts. create new matrix similar chromosomes/positions between samples counts should column this:

> exmatrix       chromosome position bm1x sm1x 1 nw_017614255.1    18550  106  200 2 nw_017616165.1    18794   50   43 3 nw_017616275.1    18344   20   15 4 nw_017614354.1    18694   51   62 5 nw_017616171.1     6199   35   18 

i have been trying various ways fail.

merge works 2 matrices if not wrong have 5. tried step step takes lot of time , @ end don't want:

> head(bcounts)         chromosome.x position.x bm1x   chromosome.y position.y bm3x 27054 nw_017614255.1      18550  106 nw_017614756.1      17486 4105 27337 nw_017616165.1      18794   50 nw_017614756.1      17749 4073 26830 nw_017616275.1      18344   20 nw_017614756.1      17297 3508 27223 nw_017614354.1      18694   51 nw_017614756.1      17628 3281 9064  nw_017616171.1       6199   35    nc_013663.1       5935 3139 3636  nw_017613961.1       2781    1    nc_013663.1       2626 3059 


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -