Last updated: 2023-08-30

Checks: 2 0

Knit directory: lab-notes/

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! 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 ba8cc1d. 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:    analysis/doc_prefix.html

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/references.Rmd) and HTML (docs/references.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
html d9c3393 1onic 2023-08-28 Build site.
html d4afa3b 1onic 2023-07-12 Build site.
html 289324b 1onic 2023-07-12 Build site.
html be52451 1onic 2023-07-12 Build site.
html a73ac21 1onic 2023-06-13 Build site.
html 41874f0 1onic 2023-06-13 Build site.
Rmd b66bbb5 1onic 2023-06-13 update

References

In this section I will describe how references (GTF/GFF2/GFF3) from either gencode or ENSEMBL can be read directly into R to create analysis-ready dataframe objects for later use. More specifically, entire genome references are quite large and take a long time to load so its advantagous to process and organize them ahead of time.

GENCODE V32 Example in R Lang.

In this subsection example code is shown on how to process and load references in R with the gencode v32 reference file (GTF).


library(rtracklayer) # this library used to read the GFF filetype
library(data.table)

### 1. 
# read in GTF
gtf_file = './gencode.v32.primary_assembly.annotation.gtf'
print(paste0('loading reference: ', gtf_file))
reference <- import.gff2(gtf_file) # columns=cols, tags=character(0) # GRanges object with 2900491 ranges and 21 metadata columns:
reference =  as.data.table(reference) # [1] 2900491      26
reference = reference %>% rowwise() %>% dplyr::mutate(ensembl_gene_id_trim = str_split(gene_id, "[.]")[[1]][1] ) # extract ENSEMBL id from full id w/ transcript id

### 2. protein coding gene reference 
gencode32_protein_coding = reference %>% dplyr::filter(type=='gene' &  gene_type=='protein_coding' ) # A tibble: 19,994 × 27 genes 
gencode32_protein_coding = gencode32_protein_coding %>% dplyr::select(where(~all(!is.na(.)))) # drop emtpy cols

### 3.  protein coding gene reference WITH lncRNAs INCLUDED  
gencode32_protein_coding_lncRNA = reference %>% dplyr::filter(type=='gene' & (gene_type=='protein_coding' | gene_type=='lncRNA')) # A tibble: 36,843 x 27 genes 
gencode32_protein_coding_lncRNA = gencode32_protein_coding_lncRNA %>% dplyr::select(where(~all(!is.na(.)))) # drop emtpy cols

### Z. bonus mito frame (for quickly loading in sc QC)
# gencode32_mito = reference %>% dplyr::filter(type=='gene' &  seqnames=='chrM') # A tibble: 37 × 27 genes
gencode32_mito2 = reference %>% dplyr::filter(type=='gene' & stringr::str_detect(gene_name, "^MT-")) # A tibble: 37 × 27 genes
gencode32_mito2 = gencode32_mito2 %>% dplyr::select(where(~all(!is.na(.)))) # drop emtpy cols