0
$\begingroup$

I have an RNAseq gene expression file (Count data) as follows, I need to conduct a Differential gene expression analysis between Patients, for that, I need to have this file as a Matrix of Rows as Genes and columns as counts (samples), how best can I get this as matrix file?

Thanks a lot for your help, Stay safe

My data looks like the following

$\endgroup$
0
$\begingroup$

Your question stated differently is as follows:

I have data in long format and need to change it to wide format. For that, I want to keep the gene_raw, use patient_id for the column names and gene_code for the row names. How can I do this easily?

Assuming you know how to read that into R as a data.frame that I'll call d:

library(tidyr)
library(dplyr)
reformatted = d %>% select(patient_id, gene_code, gene_raw) %>% spread(patient_id, gene_raw) %>% column_to_rownames(gene_code)

Or something along those lines.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.