matrix' .'array'` to Matrix in R
0
0
Entering edit mode
2.1 years ago
Jakpa ▴ 50

Hello Everyone,

I have a Data type Matrix from TCGA database of this:

matrix

I converted it to dataFrame because I want to join the gene symbol from colData to it. I got this :

dataFrame

The aim is to use the gene symbol as features for my analysis. so. I droped the Esenbl ID column and transposed the dataframe with the gene symbol as columns and samples as rows. Then I converted the dataFrame to matrix with this code :

expr_2 <- as.matrix(expr_df_3)

but when i checked the class of expr_2 it shows 'matrix' .'array'

I actually dont understand the reasons behind this . How can I make this a Matrix? I have the impression that it will have effect on my Machine Learning Pipeline.

dataframe Matrix geneexpression R • 918 views
ADD COMMENT
0
Entering edit mode

From the dataframe, let's call it df1, on your second screenshot, assuming "gene_name" column values are unique, try:

m <- as.matrix(t(df1[, -c(1,2)])
rownames(m) <- df1[, "gene_name" ]

#check the matrix
m[1:3, 1:3]
ADD REPLY
0
Entering edit mode

vinszx , I got this error Error in parse(text = x, srcfile = src): <text>:2:1: unexpected symbol 1: m <- as.matrix(t(expr[, -c(1,2)]) 2: rownames ^ Traceback:

but, I have already transposed screenshot 2 with genesybol as columns and samples as rows. but the class remain same.

ADD REPLY
0
Entering edit mode

I got this error Error in parse(text = x, srcfile = src): <text>:2:1: unexpected symbol 1: m <- as.matrix(t(expr[, -c(1,2)]) 2: rownames ^ Traceback:

but, I have already transposed screenshot 2 with genesymbol as columns and samples as rows. but the class remain same

ADD REPLY

Login before adding your answer.

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