Attempt to set 'rownames' on an object with no dimensions
1
1
Entering edit mode
4.1 years ago
ks.sholohova ▴ 30

Hello everyone! My name is Kseniia and I am new here!

I did encounter some problems while analyzing american gut data. Here is the code for it:

library(devtools)
devtools::install_github("zdk123/SpiecEasi")   
library(SpiecEasi) 
SpiecEasi.matrix <- spiec.easi(amgut1.filt,  
                           method = 'glasso',  
                           lambda.min.ratio = 1e-2,  
                           nlambda = 20,    
                           icov.select.params=list(rep.num=50))

The next line suppose to add OTU names to rows and columns

rownames(SpiecEasi.matrix$refit) <- colnames(amgut1.filt)

Then this error appeared: Error in rownames<-(*tmp*, value = c("OTU_1", "OTU_2", "OTU_3", "OTU_4", : attempt to set 'rownames' on an object with no dimensions

I understood that it appears because $refit is a list. But I don't know how to fix it. If anyone had the same error, I would greatly appreciate your help with its solution.

Thanks in advance! Kseniia

R microbiome spieceasi • 6.5k views
ADD COMMENT
0
Entering edit mode

hello everyone, I got the same error for a function immuCellAI_new;

result <- ImmuCellAI_new(countData = expr_data_log22, data_type = "rnaseq", group_tag = 1, response_tag = 0, customer = 0)
Error in `rownames<-`(`*tmp*`, value = colnames(countData)) : 
  attempt to set 'rownames' on an object with no dimensions,  CountDATA is a matrix with genes expression, the colnames express the sample and the rownames are the gene

, how to fix that, when I run this commande, I got value; dn NULL (empty, nd )L, value chr[1:1082] et x NULL (empty)

ADD REPLY
3
Entering edit mode
4.1 years ago

Try this:

rownames(SpiecEasi.matrix$refit$stars) <- colnames(amgut1.filt)
ADD COMMENT
1
Entering edit mode

Thank you very much, Andres! Now everything perfectly works.

I just want to make sure please that I understand the concept, if you don't mind. So, SpiecEasi.matrix$refit is a list. That's why I got this error. Then by using SpiecEasi.matrix$refit$stars I refer to numeric object that is dimensional already and, hence, it works.

Have a nice day!

ADD REPLY

Login before adding your answer.

Traffic: 2495 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