使用cbind时出现R错误

时间:2012-11-20 08:30:38

标签: r

我尝试使用cbind组合2个向量,两个向量大小相同,我运行代码时出错,向量很大,长度= 57605.

 final=cbind (counts1,tx_by_gene)

> > Error: cannot allocate vector of size 225 Kb R(473,0xa0cb8540) malloc: *** mmap(size=233472) failed (error code=12)
> *** error: can't allocate region
> *** set a breakpoint in malloc_error_break to debug R(473,0xa0cb8540) malloc: *** mmap(size=233472) failed (error code=12)
> *** error: can't allocate region
> *** set a breakpoint in malloc_error_break to debug

任何人都可以帮助我,为什么我会遇到这个错误?或其他一些组合2个向量的方法?

谢谢

> str(counts1) =  int [1:57605] 0 0 0 0 0 0 0 0 0 0 ... 

>str(tx_by_gene)
> Formal class 'GRangesList' [package "GenomicRanges"] with 5 slots   ..@ partitioning   :Formal class 'PartitioningByEnd' [package
> "IRanges"] with 5 slots   .. .. ..@ end            : int [1:57605] 3 5
> 12 17 27 36 42 46 58 60 ...   .. .. ..@ NAMES          : chr [1:57605]
> "ENSG00000000003" "ENSG00000000005" "ENSG00000000419"
> "ENSG00000000457" ...   .. .. ..@ elementMetadata: NULL   .. .. ..@
> elementType    : chr "integer"   .. .. ..@ metadata       : list()  
> ..@ unlistData     :Formal class 'GRanges' [package "GenomicRanges"]
> with 7 slots   .. .. ..@ seqnames       :Formal class 'Rle' [package
> "IRanges"] with 5 slots   .. .. .. .. ..@ values         : Factor w/
> 93 levels "chr1","chr2",..: 8 20 1 6 1 8 6 3 7 13 ...   .. .. .. ..
> ..@ lengths        : int [1:41694] 5 7 30 18 21 6 2 9 43 23 ...   ..
> .. .. .. ..@ elementMetadata: NULL   .. .. .. .. ..@ elementType    :
> chr "ANY"   .. .. .. .. ..@ metadata       : list()   .. .. ..@ ranges
> :Formal class 'IRanges' [package "IRanges"] with 6 slots   .. .. .. ..
> ..@ start          : int [1:191891] 99883667 99887538 99888439
> 99839799 99848621 49551404 49551404 49551404 49551433 49551482 ...  
> .. .. .. .. ..@ width          : int [1:191891] 8137 4149 6550 15084
> 3908 23684 23684 23689 10966 23577 ...   .. .. .. .. ..@ NAMES        
> : NULL   .. .. .. .. ..@ elementMetadata: NULL   .. .. .. .. ..@
> elementType    : chr "integer"   .. .. .. .. ..@ metadata       :
> list()   .. .. ..@ strand         :Formal class 'Rle' [package
> "IRanges"] with 5 slots   .. .. .. .. ..@ values         : Factor w/ 3
> levels "+","-","*": 2 1 2 1 2 1 2 1 2 1 ...   .. .. .. .. ..@ lengths 
> : int [1:28670] 3 2 12 10 9 6 16 2 13 8 ...   .. .. .. .. ..@
> elementMetadata: NULL   .. .. .. .. ..@ elementType    : chr "ANY"  
> .. .. .. .. ..@ metadata       : list()   .. .. ..@ seqlengths     :
> Named int [1:93] 249250621 243199373 198022430 191154276 180915260
> 171115067 159138663 155270560 146364022 141213431 ...   .. .. .. ..-
> attr(*, "names")= chr [1:93] "chr1" "chr2" "chr3" "chr4" ...   .. ..
> ..@ elementMetadata:Formal class 'DataFrame' [package "IRanges"] with
> 6 slots   .. .. .. .. ..@ rownames       : NULL   .. .. .. .. ..@
> nrows          : int 191891   .. .. .. .. ..@ elementMetadata: NULL  
> .. .. .. .. ..@ elementType    : chr "ANY"   .. .. .. .. ..@ metadata 
> : list()   .. .. .. .. ..@ listData       :List of 2   .. .. .. .. ..
> ..$ tx_id  : int [1:191891] 93738 93739 93740 93736 93737 175481
> 175482 175480 175483 175484 ...   .. .. .. .. .. ..$ tx_name: chr
> [1:191891] "ENST00000373020" "ENST00000496771" "ENST00000494424"
> "ENST00000373031" ...   .. .. ..@ elementType    : chr "ANY"   .. ..
> ..@ metadata       : list()   ..@ elementMetadata:Formal class
> 'DataFrame' [package "IRanges"] with 6 slots   .. .. ..@ rownames     
> : NULL   .. .. ..@ nrows          : int 57605   .. .. ..@
> elementMetadata: NULL   .. .. ..@ elementType    : chr "ANY"   .. ..
> ..@ metadata       : list()   .. .. ..@ listData       : list()   ..@
> elementType    : chr "GRanges"   ..@ metadata       : list()

2 个答案:

答案 0 :(得分:3)

对象tx_by_gene不是矢量。您可以使用is.vector功能

进行检查
is.vector(counts1) 
is.vector(tx_by_gene)

当然,可以定义方法,以便可以组合两个对象

答案 1 :(得分:0)

这些向量对于R来说不应该太大。你可能在cbind()操作之前耗尽了大量内存。使用ls()查看您目前拥有的对象,并使用rm()删除不再需要的对象。