Posts by Xianjun Dong
Author: Xianjun Dong
An easy to convert list to long table
Feed: R-bloggers. Author: Xianjun Dong. [This article was first published on One Tip Per Day, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here) Want to share your content on R-bloggers? click here if you have a blog, or here if you don't. Say you have a list with different lengths of vectors, e.g. > head(genesets_list)$KEGG_GLYCOLYSIS_GLUCONEOGENESIS [1] “ACSS2” “GCK” “PGK2” “PGK1” “PDHB” “PDHA1” “PDHA2” “PGM2” “TPI1” “ACSS1” “FBP1” “ADH1B” “HK2” “ADH1C” “HK1” “HK3” “ADH4” ... Read More
A bug related to R factor
Feed: R-bloggers. Author: Xianjun Dong. [This article was first published on One Tip Per Day, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here) Want to share your content on R-bloggers? click here if you have a blog, or here if you don't. Note a bug in my code today. Sometimes you need to put a certain level (e.g. healthy control) in the first position for your covariance. Here is my old code:dds[[variable]]=factor(dds[[variable]])levels(dds[[variable]])= union(variable_REF, levels(dds[[variable]])))Note that this can cause problem. For example, you have two levels: HC and AD in your diagnosis. By default, ... Read More
Note (2) for DESeq2 time series data analysis
Feed: R-bloggers. Author: Xianjun Dong. [This article was first published on One Tip Per Day, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here) Want to share your content on R-bloggers? click here if you have a blog, or here if you don't. More notes on using LRT to test time-series data. Thanks for the discussion with Jie. swapping the levels of time factor won’t change the LRT results, as if the time variable is a factor, LRT won’t see it as a trajectory analysis but rather a factor analysis (e.g. condition-specific difference at ... Read More
Making Art in R
Feed: R-bloggers. Author: Xianjun Dong. Amazing artworks people made in R: See their source code and more arts at:http://www.r-graph-gallery.com/286-antonio-sanchez-dataart/ Related To leave a comment for the author, please follow the link and comment on their blog: One Tip Per Day. R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more... If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, ... Read More
PCA plot with fill, color, and shape all together
Feed: R-bloggers. Author: Xianjun Dong. When I plotted the PCA results (e.g. scatter plot for PC1 and PC2) and was about to annotate the dataset with different covariates (e.g. gender, diagnosis, and ethic group), I noticed that it’s not straightforward to annotate >2 covariates at the same time using ggplot. Here is what works for me in ggplot: pcaData percentVar ggplot(pcaData, aes(x = PC1, y = PC2, color = factor(Diagnosis), shape = factor(Ethnicity))) + geom_point(size =3, aes(fill=factor(Diagnosis), alpha=as.character(Sex))) + geom_point(size =3) + scale_shape_manual(values=c(21,22)) + scale_alpha_manual(values=c(“F”=0, “M”=1)) + xlab(paste0(“PC1: “, percentVar[1], “% variance”)) + ylab(paste0(“PC2: “, percentVar[2], “% variance”)) + ggtitle(“PCA ... Read More
Recent Comments