This is a test version of Biostars. For the public version, visit https://www.biostars.org.
matrix' .'array'` to Matrix in R

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

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]

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.

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

0 answers

No answers yet.

Log in to answer this question.