Archive for October, 2012

Split a chromosome name and location type string into its constituent parts in R

Easy to do with a regular expression and the strsplit function in R. The | operator means “or”. For example for “chr15:88120587-88121480″:
> unlist(strsplit(“chr15:88120587-88121480″, “chr|:|-”))[2:4]
[1] “15″ “88120587″ “88121480″

Principal Components Analysis Explained using R

Here, we will explain principle component analysis (PCA) by stepping though the algorithm manually and reproducing the output of the prcomp() function in R, which is normally used to do PCA.
First make up some data and plot it; in terms of gene expression analysis, we can think of the rows of the matrix below as [...]