how to create csv file with name of gene from unique ID of lcpm ?
1
0
Entering edit mode
Björn • 0
@bjorn-12199
Last seen 5.5 years ago
CH

after converting raw counts to cpm from data file using command

lcpm<-cpm(y, log=T)
head(lcpm)

gives first row with unique numeric ID which denotes gene names from data file. How to export name of genes into *.csv file but with name of genes ?

write.csv(highly_variable_lcpm, row.names=y2$genes, file = "highly_variable_lcpm_genes.csv")

I get error message as below

Error in write.table(highly_variable_lcpm, row.names = y2$genes, file = "highly_variable_lcpm_genes.csv", : invalid 'row.names' specification

How to solve the problem ? THx

 

 

edgeR lcpm bioconductor • 1.2k views
ADD COMMENT
1
Entering edit mode
Aaron Lun ★ 28k
@alun
Last seen 3 hours ago
The city by the bay

Read ?write.csv.

row.names: either a logical value indicating whether the row names of
          ‘x’ are to be written along with ‘x’, or a character vector
          of row names to be written.

The argument needs to be a character vector. y2$genes is a data.frame, hence the error.

ADD COMMENT
0
Entering edit mode

Sorry, still can't find the solution

ADD REPLY
0
Entering edit mode

Just give the character vector of gene names to write.csv. Presumably the gene names or symbols are stored as a column in y2$genes, so just pull out the relevant column and use that as row.names=.

ADD REPLY
0
Entering edit mode

I did it as you have said which I have in my first post. 

ADD REPLY
0
Entering edit mode

If you in an interactive r session do your analysis and type y2$genes you will see that this is not a vector. You hence have to select one of the columns (= a vector) of this dataframe to use as row names.

ADD REPLY

Login before adding your answer.

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