-1

我尝试使用 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

谁能帮助我为什么会出现此错误?或其他组合这两个向量的方式?

谢谢你

> 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()
4

2 回答 2

3

该对象tx_by_gene不是向量。您可以使用该is.vector功能进行检查

is.vector(counts1) 
is.vector(tx_by_gene)

当然,也可以定义一个方法,这样两个对象就可以组合起来

于 2012-11-20T09:45:35.730 回答
0

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

于 2012-11-20T09:08:50.640 回答