Last active
April 13, 2018 23:42
-
-
Save joonan30/4f0d50a89d9b2bfa6d053246b2226ab3 to your computer and use it in GitHub Desktop.
Quick meal prep in R
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Get date | |
| date = sapply(strsplit(as.character(Sys.Date()), '-', fixed = T), paste, collapse = "") | |
| ## biomart and AnnotationDbi | |
| # Map a gene id to get an ENTREZ id. | |
| require(AnnotationDbi) | |
| require(org.Mm.eg.db) # mice | |
| entrez = mapIds(org.Mm.eg.db, | |
| keys=ens_gene, # has to be a vector | |
| column=c('SYMBOL'), | |
| keytype='ENTREZID', | |
| multiVals='first') | |
| # Get biomart | |
| bm = useMart("ENSEMBL_MART_ENSEMBL", "mmusculus_gene_ensembl", host="oct2016.archive.ensembl.org") | |
| # list attributes | |
| a = listAttributes(bm) | |
| # list filters | |
| f= listFilters(bm) | |
| # Shop biomart | |
| bm1 = getBM(attributes = c("ensembl_gene_id", | |
| "chromosome_name", | |
| "start_position", | |
| "end_position", | |
| "percentage_gc_content"), | |
| mart=bm) | |
| # change multiple columns into factor | |
| df %>% mutate_if(is.character,as.factor) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment