I have this data frame :
and I want to remove those rows which contain NA values from the log2fold change column
How can I do this through R?
If your data frame is called res, then:
I also want to rename column 'X' to 'gene names' . How can i do it?
colnames(res) <- 'gene names'
idx <- which(colnames(res) == 'X')
colnames(res)[idx] <- 'gene names'
I am trying this to make a heatmap:
ntd <- normTransform(dds)
select <- order(rowMeans(counts(dds,normalized=TRUE)),
df <- as.data.frame(colData(dds)[,c("group")])
pheatmap(assay(ntd)[select,], cluster_rows=FALSE, show_rownames=FALSE,
But it is giving me this error:
Error in check.length("fill"): 'gpar' element 'fill' must not be length 0
The data frame which I am using for annotation is:
kindly help me
For dataframe manipulation you should look into the dplyr and tidyr libraries. You can take a look a this cheatsheet for example.
You can remove NAs and rename columns as follows:
dplyr::rename(gene_names = X)
No need to load dplyr if you call it's functions directly though.
It helps avoiding confusion, since these functions also exist in other libraries
ponganta means you don't need the library(dplyr) step if you call functions like this dplyr::filter()...
whatever, %>% need this. :-D
Agreed, especially regarding dplyr::rename(). I didn't think about that.
Regarding these two functions, there are oftentimes namespace collisions with other packages, I guess this is what @rioualen meant. Good catch.
Login before adding your answer.
Use of this site constitutes acceptance of our User Agreement and Privacy