Row names showing up as row numbers in R - r

This probably has a simple fix, but I'm relatively new to using R and could use some assistance.
The toy data I'm using for a gene network analysis has rows that look like this:
whereas the data that I've uploaded has rows that look like this:
.
The code I'm using refers to the row names to map on as gene names. I am able to successfully run this analysis, however, the output I end up with has lists of row numbers where there should be lists of gene names.
Is there a simple way that I can convert my data into the toy data format so that the row names are gene names instead of numbers?

Related

With R changing row names of a dataframe

i have a Dataframe like this.
My column names are F02283_L1_S49_L006, F02284_L1_S50_L006 etc. which is totally fine.
But my row names are 1,2,3,4 etc. and i dont want that. Instead of that i want ENSG00000182199, ENSG00000157870 etc.
Im new in R and i have to process this dataframe. I will my dataframe as a matrix, so they muss contain just numeric values. How can i do that with R?

RNAseq: Convert RNA identifiers to Genes

I am using DEseq2 for DE analysis and want to analyze a publshed data set.
However, the count matrix provided does not show ENSEMBL gene IDs but mRNA transcript ids instead, i.e. the first column looks like that: XM_0176201594.2
Could somebody tell me how to convert, or fetch from GTF to get the usual count matrix that serves as input for DESeq2? Basically, we are looking at a matrix, where several lines correspond to the same gene, right?
Thanks in advance!

Reshape dataframe with numeric and character variables

probabily it is refusee.
I want to transpose a data frame that has both numeric and character columns. I have some lines where the id is repeated 2 or even more times. I would like to have a final dataframe where I have this data in one line.
I thought about using both the data.table and reshape2 library (they have similar functions) but I can't find the right combination to do what I want and I'm going crazy. Could someone give me some help?
Here a modified example of my database
example_data <-data.frame(cod=c(20,20,20,20,20,20,20,40,80,80,80,80,80,240),
id=c(44,68,137,150,186,236,289,236,44,150,155,236,68,289),
textVar=c('aaaa','aaaa','aaaa bbbb','aaaa','cccc','cccc','cccc bbb','dddd','dddd cccc','dddd','ffff','ffff gggg','ffff','hhhh'),
ww=c(4,4,4,4,4,4,4,45,118,118,118,118,118,118))
If for example consider the column with id=44 my output is like this:
exampleRow <-data.frame(cod_1=c(20),id=c(44),textVar_1=c('aaaa'),ww_1=c(4),cod_2=c(80),id=c(44),textVar_2=c('dddd cccc'),ww_2=c(118))

How to copy multiple columns to a new dataframe in R

I have a data set (df2) with 400 columns and thousands of rows. The columns all have different names but all have either 'typeP' or 'typeR' at the end of their names. They are not ordered sequentially (eg. P,P,P,P,R,R,R,R) but randomly (P,P,R,R,R,P,R,P etc). I want to create a new data frame with just those columns whose names have 'type P' in their names.
I'm very new to R and so far I have only managed to find the positions of those columns using: grep("typeP",colnames(df2)). Any help would be appreciated!
After we get the index, we can use that to subset the initial dataset
df3 <- df2[grep("typeP",colnames(df2))]

copy information from one dataframe to another

I have an output dataframe that looks like this:
After summing the values in the “Flux” column and a couple other analyses I get an output that looks like this. This is a summarized version of the original dataframe.
I need the new output to include the “Treatment” column in from the first output. So that the final dataframe has three columns: ID, Total_CO2, Treatment Does anyone know how to do this?

Resources