Last updated: 2023-02-13
Checks: 7 0
Knit directory: muse/
This reproducible R Markdown analysis was created with workflowr (version 1.7.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(20200712)
was run prior to running
the code in the R Markdown file. Setting a seed ensures that any results
that rely on randomness, e.g. subsampling or permutations, are
reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.
The results in this page were generated with repository version 28276f9. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.
Note that you need to be careful to ensure that all relevant files for
the analysis have been committed to Git prior to generating the results
(you can use wflow_publish
or
wflow_git_commit
). workflowr only checks the R Markdown
file, but you know if there are other scripts or data files that it
depends on. Below is the status of the Git repository when the results
were generated:
Ignored files:
Ignored: .Rhistory
Ignored: .Rproj.user/
Ignored: r_packages_4.1.2/
Ignored: r_packages_4.2.0/
Untracked files:
Untracked: analysis/cell_ranger.Rmd
Untracked: analysis/tss_xgboost.Rmd
Untracked: data/HG00702_SH089_CHSTrio.chr1.vcf.gz
Untracked: data/HG00702_SH089_CHSTrio.chr1.vcf.gz.tbi
Untracked: data/ncrna_NONCODE[v3.0].fasta.tar.gz
Untracked: data/ncrna_noncode_v3.fa
Unstaged changes:
Modified: analysis/graph.Rmd
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
These are the previous versions of the repository in which changes were
made to the R Markdown (analysis/ensembldb.Rmd
) and HTML
(docs/ensembldb.html
) files. If you’ve configured a remote
Git repository (see ?wflow_git_remote
), click on the
hyperlinks in the table below to view the files as they were in that
past version.
File | Version | Author | Date | Message |
---|---|---|---|---|
Rmd | 28276f9 | Dave Tang | 2023-02-13 | Using ensembldb |
The ensembldb
package can be used to retrieve genomic
and protein annotations and to map between protein, transcript, and
genome coordinates. This mapping relies on annotations of proteins
(their sequences) to their encoding transcripts which are stored in
EnsDb
databases.
All functions, except
proteinToGenome
andtranscriptToGenome
returnIRanges
with negative coordinates if the mapping failed (e.g. because the identifier is unknown to the database, or if, for mappings to and from protein coordinates, the input coordinates are not within the coding region of a transcript).proteinToGenome
andtranscriptToGenome
return emptyGRanges
if mappings fail.
To begin, install the ensembldb and AnnotationHub packages.
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
if (!require("ensembldb", quietly = TRUE))
BiocManager::install("ensembldb")
if (!require("AnnotationHub", quietly = TRUE))
BiocManager::install("AnnotationHub")
library(ensembldb)
library(AnnotationHub)
The AnnotationHub server provides easy R / Bioconductor access to large collections of publicly available whole genome resources, e.g,. ENSEMBL genome fasta or gtf files, UCSC chain resources, ENCODE data tracks at UCSC, etc.
Create an AnnotationHub
object.
ah <- AnnotationHub(ask = FALSE)
snapshotDate(): 2022-10-31
Query.
ensdb_homo <- query(ah, c("EnsDb", "Homo sapiens"))
ensdb_homo
AnnotationHub with 23 records
# snapshotDate(): 2022-10-31
# $dataprovider: Ensembl
# $species: Homo sapiens
# $rdataclass: EnsDb
# additional mcols(): taxonomyid, genome, description,
# coordinate_1_based, maintainer, rdatadateadded, preparerclass, tags,
# rdatapath, sourceurl, sourcetype
# retrieve records with, e.g., 'object[["AH53211"]]'
title
AH53211 | Ensembl 87 EnsDb for Homo Sapiens
AH53715 | Ensembl 88 EnsDb for Homo Sapiens
AH56681 | Ensembl 89 EnsDb for Homo Sapiens
AH57757 | Ensembl 90 EnsDb for Homo Sapiens
AH60773 | Ensembl 91 EnsDb for Homo Sapiens
... ...
AH95744 | Ensembl 104 EnsDb for Homo sapiens
AH98047 | Ensembl 105 EnsDb for Homo sapiens
AH100643 | Ensembl 106 EnsDb for Homo sapiens
AH104864 | Ensembl 107 EnsDb for Homo sapiens
AH109336 | Ensembl 108 EnsDb for Homo sapiens
Latest available Ensembl version.
latest <- nrow(mcols(ensdb_homo))
edb <- ensdb_homo[[latest]]
loading from cache
edb
EnsDb for Ensembl:
|Backend: SQLite
|Db type: EnsDb
|Type of Gene ID: Ensembl Gene ID
|Supporting package: ensembldb
|Db created by: ensembldb package from Bioconductor
|script_version: 0.3.7
|Creation time: Fri Oct 28 05:24:43 2022
|ensembl_version: 108
|ensembl_host: localhost
|Organism: Homo sapiens
|taxonomy_id: 9606
|genome_build: GRCh38
|DBSCHEMAVERSION: 2.2
| No. of genes: 70616.
| No. of transcripts: 275721.
|Protein data available.
The
proteinToGenome
function allows to map coordinates within the amino acid sequence of a protein to the corresponding DNA sequence on the genome. A protein identifier and the coordinates of the sequence within its amino acid sequence are required and have to be passed as anIRanges
object to the function. The protein identifier can either be passed as names of this object, or provided in a metadata column (mcols).
The example below (from the vignette) maps positions 5 to 9 within the amino acid sequence of the protein ENSP00000385415.
GAGE10_prt <- IRanges(start = 5, end = 9, names = "ENSP00000385415")
GAGE10_gnm <- proteinToGenome(GAGE10_prt, edb)
Fetching CDS for 1 proteins ... 1 found
Checking CDS and protein sequence lengths ... 1/1 OK
GAGE10_gnm
$ENSP00000385415
GRanges object with 1 range and 7 metadata columns:
seqnames ranges strand | protein_id tx_id
<Rle> <IRanges> <Rle> | <character> <character>
[1] X 49304872-49304886 + | ENSP00000385415 ENST00000407599
exon_id exon_rank cds_ok protein_start protein_end
<character> <integer> <logical> <integer> <integer>
[1] ENSE00001692657 2 TRUE 5 9
-------
seqinfo: 1 sequence from GRCh38 genome
The result is returned in a list, with one element for each range in
the input IRanges
.
Below is an example with two proteins.
two_prt <- IRanges(
start = c(6, 15),
end = c(6, 15),
names = c("ENSP00000366863", "ENSP00000358262")
)
two_prt_to_gnm <- proteinToGenome(two_prt, edb)
Fetching CDS for 2 proteins ... 2 found
Checking CDS and protein sequence lengths ... 2/2 OK
two_prt_to_gnm
$ENSP00000366863
GRanges object with 1 range and 7 metadata columns:
seqnames ranges strand | protein_id tx_id
<Rle> <IRanges> <Rle> | <character> <character>
[1] 13 75481750-75481752 - | ENSP00000366863 ENST00000377636
exon_id exon_rank cds_ok protein_start protein_end
<character> <integer> <logical> <integer> <integer>
[1] ENSE00003893703 1 TRUE 6 6
-------
seqinfo: 2 sequences from GRCh38 genome
$ENSP00000358262
GRanges object with 1 range and 7 metadata columns:
seqnames ranges strand | protein_id tx_id
<Rle> <IRanges> <Rle> | <character> <character>
[1] 1 147242746-147242748 + | ENSP00000358262 ENST00000369258
exon_id exon_rank cds_ok protein_start protein_end
<character> <integer> <logical> <integer> <integer>
[1] ENSE00003728289 1 TRUE 15 15
-------
seqinfo: 2 sequences from GRCh38 genome
We use sapply()
to convert the results into a data
frame.
get_pos <- function(x, add_chr = TRUE){
chr <- as.character(seqnames(x))
if(add_chr){
chr <- paste0("chr", chr)
}
list(
chr = chr,
start = start(x),
end = end(x)
)
}
as.data.frame(
t(sapply(two_prt_to_gnm, get_pos))
)
chr start end
ENSP00000366863 chr13 75481750 75481752
ENSP00000358262 chr1 147242746 147242748
sessionInfo()
R version 4.2.0 (2022-04-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.4 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/liblapack.so.3
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats4 stats graphics grDevices utils datasets methods
[8] base
other attached packages:
[1] AnnotationHub_3.6.0 BiocFileCache_2.6.0 dbplyr_2.3.0
[4] ensembldb_2.22.0 AnnotationFilter_1.22.0 GenomicFeatures_1.50.4
[7] AnnotationDbi_1.60.0 Biobase_2.58.0 GenomicRanges_1.50.2
[10] GenomeInfoDb_1.34.9 IRanges_2.32.0 S4Vectors_0.36.1
[13] BiocGenerics_0.44.0 BiocManager_1.30.19 workflowr_1.7.0
loaded via a namespace (and not attached):
[1] ProtGenerics_1.30.0 bitops_1.0-7
[3] matrixStats_0.63.0 fs_1.6.1
[5] bit64_4.0.5 filelock_1.0.2
[7] progress_1.2.2 httr_1.4.4
[9] rprojroot_2.0.3 tools_4.2.0
[11] bslib_0.4.2 utf8_1.2.3
[13] R6_2.5.1 lazyeval_0.2.2
[15] DBI_1.1.3 withr_2.5.0
[17] tidyselect_1.2.0 prettyunits_1.1.1
[19] processx_3.8.0 bit_4.0.5
[21] curl_5.0.0 compiler_4.2.0
[23] git2r_0.31.0 cli_3.6.0
[25] xml2_1.3.3 DelayedArray_0.24.0
[27] rtracklayer_1.58.0 sass_0.4.5
[29] callr_3.7.3 rappdirs_0.3.3
[31] stringr_1.5.0 digest_0.6.31
[33] Rsamtools_2.14.0 rmarkdown_2.20
[35] XVector_0.38.0 pkgconfig_2.0.3
[37] htmltools_0.5.4 MatrixGenerics_1.10.0
[39] fastmap_1.1.0 rlang_1.0.6
[41] rstudioapi_0.14 RSQLite_2.2.20
[43] shiny_1.7.4 jquerylib_0.1.4
[45] BiocIO_1.8.0 generics_0.1.3
[47] jsonlite_1.8.4 BiocParallel_1.32.5
[49] dplyr_1.1.0 RCurl_1.98-1.10
[51] magrittr_2.0.3 GenomeInfoDbData_1.2.9
[53] Matrix_1.5-3 Rcpp_1.0.10
[55] fansi_1.0.4 lifecycle_1.0.3
[57] stringi_1.7.12 whisker_0.4.1
[59] yaml_2.3.7 SummarizedExperiment_1.28.0
[61] zlibbioc_1.44.0 grid_4.2.0
[63] blob_1.2.3 parallel_4.2.0
[65] promises_1.2.0.1 crayon_1.5.2
[67] lattice_0.20-45 Biostrings_2.66.0
[69] hms_1.1.2 KEGGREST_1.38.0
[71] knitr_1.42 ps_1.7.2
[73] pillar_1.8.1 rjson_0.2.21
[75] codetools_0.2-18 biomaRt_2.54.0
[77] BiocVersion_3.16.0 XML_3.99-0.13
[79] glue_1.6.2 evaluate_0.20
[81] getPass_0.2-2 png_0.1-8
[83] vctrs_0.5.2 httpuv_1.6.8
[85] purrr_1.0.1 assertthat_0.2.1
[87] cachem_1.0.6 xfun_0.37
[89] mime_0.12 xtable_1.8-4
[91] restfulr_0.0.15 later_1.3.0
[93] tibble_3.1.8 GenomicAlignments_1.34.0
[95] memoise_2.0.1 interactiveDisplayBase_1.36.0
[97] ellipsis_0.3.2