Skip to content

Instantly share code, notes, and snippets.

@daskelly
Created August 20, 2018 18:11
Show Gist options
  • Save daskelly/0121e4494da3fdd7e06072cb2bf05dca to your computer and use it in GitHub Desktop.
Save daskelly/0121e4494da3fdd7e06072cb2bf05dca to your computer and use it in GitHub Desktop.
code to filter genes to find those expressed on cell surface
library(tidyverse)
library(biomaRt)
genes <- # FILL ME IN ... Should be a vector of gene names
markers <- # FILL ME IN ... Should be a data.frame with at least one column called mgi_symbol
ensembl <- useMart("ensembl", dataset="mmusculus_gene_ensembl") # Mouse
# GO:0009986 is cell surface
go_cellsurf <- "GO:0009986"
gene.data <- getBM(attributes=c("mgi_symbol", "ensembl_gene_id", "go_id"),
filters="go", values=go_cellsurf, mart=ensembl) %>%
dplyr::filter(go_id == go_cellsurf)
markers_cell_surface <- dplyr::filter(markers, gene %in% gene.data$mgi_symbol)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment