library(dplyr) library(knitr) knitr::opts_chunk$set(echo = TRUE,message=FALSE, warning=FALSE)
library(MSnID) library(EnsDb.Hsapiens.v86) library(rtracklayer)
remote_dir=file.path("https://raw.githubusercontent.com", "PacktPublishing/R-Bioinformatics-Cookbook/master/datasets/ch6") msnid_file <- "HeLa_180123_m43_r2_CAM.mzid.gz" if (!file.exists(msnid_file)) { download.file(file.path(remote_dir, msnid_file), msnid_file) } msnid <- MSnID() msnid <- read_mzIDs(msnid, msnid_file)
real_hits <- msnid@psms[! msnid@psms$isDecoy, ] required_info <- real_hits[, c("spectrumID", "pepSeq", "accession", "start", "end")]
uniprot_ids <- unlist(lapply(strsplit(required_info$accession, "\\|"), function(x){x[2]}) ) uniprot_ids <- uniprot_ids[!is.na(uniprot_ids)]
edb <- EnsDb.Hsapiens.v86 genes_for_prots <- genes(edb, filter = UniprotFilter(uniprot_ids), columns = c("gene_name", "gene_seq_start", "gene_seq_end", "seq_name"))
genes_for_prots %>% head()
seqnames(genes_for_prots) %>% as.vector() %>% unique() %>% sort() %>% head() %>% kable()
snames <- as.vector(seqnames(genes_for_prots) ) genes_for_prots <- genes_for_prots[nchar(snames) <= 2 & snames != "MT"] # like chr19 but not longer # two conventions: chromosome chrM on UCSF, and "MT" on EBI
track <- rtracklayer::GRangesForUCSCGenome("hg38", paste0("chr",seqnames(genes_for_prots)), ranges=ranges(genes_for_prots), strand=strand(genes_for_prots), genes_for_prots$gene_name, genes_for_prots$uniprot_id )
session <- browserSession("UCSC") track(session, "my_peptides") <- track first_peptide <- track[1] view <- browserView(session, first_peptide * -5, pack = "my_peptides")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.