2
votes

I have a gene expression dataset that currently has columns of patient samples and rows of genes. I need to transpose the dataset so that the genes are now columns and rows are now patient samples using R. I have found a few ways yet none have been successful. I appreciate your help in advance! :)

1

1 Answers

5
votes

Make a data frame as follows:

df <- data.frame(Joe = c(45,123,1007), Mary=c(1,456,103))
rownames(df) <- c("Wnt1", "Bmp4", "BRCA2")
df
       Joe Mary
Wnt1    45    1
Bmp4   123  456
BRCA2 1007  103

And to transpose it, simply:

 t(df)
     Wnt1 Bmp4 BRCA2
Joe    45  123  1007
Mary    1  456   103