Scenario 1
I have a datamatrix of RNAseq data, the ID column looks something like the following
----------------- head(geneIDs) ----------------- "Xkr4|497097|locus1of1|1" "Sox17|20671|locus1of1|5" "Mrpl15|27395|locus1of1|3" "Lypla1|18777|locus1of1|1" "Tcea1|21399|locus1of1|3" "Rgs20|58175|locus1of1|3"
I want to parse them out and retain only the gene symbols, “sapply” here is very handy
as.vector(sapply (geneIDs, FUN = function (x) {strsplit(x, "\\|")[[1]][1]}))
Running the above line get me the following:
"Xkr4" "Sox17" "Mrpl15" "Lypla1" "Tcea1" "Rgs20"