Last updated: 2021-01-21

Checks: 7 0

Knit directory: invitroOA_pilot_repository/

This reproducible R Markdown analysis was created with workflowr (version 1.6.2). 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(20210119) 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 78cfbcd. 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:    .DS_Store
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    data/.DS_Store
    Ignored:    data/external_scRNA/.DS_Store

Unstaged changes:
    Deleted:    analysis/figure/powerAnalysis.Rmd/curve-1.png
    Deleted:    analysis/figure/powerAnalysis.Rmd/hypoxia-1.png
    Deleted:    analysis/figure/powerAnalysis.Rmd/hypoxia-2.png
    Deleted:    analysis/figure/powerAnalysis.Rmd/hypoxia-3.png
    Deleted:    analysis/figure/powerAnalysis.Rmd/hypoxia-4.png
    Deleted:    analysis/figure/powerAnalysis.Rmd/hypoxia-5.png
    Deleted:    analysis/figure/powerAnalysis.Rmd/hypoxia-6.png
    Deleted:    analysis/figure/powerAnalysis.Rmd/hypoxia-7.png
    Deleted:    analysis/figure/powerAnalysis.Rmd/hypoxia-8.png

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/download_gene_annotation.Rmd) and HTML (docs/download_gene_annotation.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 e0e89e1 Anthony Hung 2021-01-21 download annotations and finish preprocessing of bulkRNA
html e0e89e1 Anthony Hung 2021-01-21 download annotations and finish preprocessing of bulkRNA
Rmd 28f57fa Anthony Hung 2021-01-19 Add files for analysis

Introduction

This code downloads gene annotations and creates a reference table to interpret GO enrichments.

Load data

library(biomaRt)
library(dplyr)

Attaching package: 'dplyr'
The following object is masked from 'package:biomaRt':

    select
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
#load count data
counts <- readRDS("data/raw_counts_relabeled.rds")
genes <- rownames(counts)

Download from Ensembl

Download human exons (Ensembl 93, Jul 2018, grch38.p12, hg38)

ensembl <- useMart(host = "jul2018.archive.ensembl.org/",
                   biomart = "ENSEMBL_MART_ENSEMBL",
                   dataset = "hsapiens_gene_ensembl")
# attributePages(ensembl)
# [1] "feature_page" "structure" "homologs" "sequences" "snp" "snp_somatic"
atts <- listAttributes(ensembl, page = "feature_page")

# Obtain annotation results that are one per gene
basic <- getBM(attributes = c("ensembl_gene_id",
                            "external_gene_name",
                            "chromosome_name",
                            "description",
                            "start_position",
                            "end_position"),
             filters = "ensembl_gene_id",
             values = genes,
             mart = ensembl)
stopifnot(sort(genes) == sort(basic$ensembl_gene_id))

# Obtain phenotype descriptions
pheno <- getBM(attributes = c("ensembl_gene_id",
                              "phenotype_description"),
               filters = "ensembl_gene_id",
               values = genes,
               mart = ensembl)
stopifnot(genes %in% unique(pheno$ensembl_gene_id))

# Obtain GO categories
go <- getBM(attributes = c("ensembl_gene_id",
                           "go_id",
                           "name_1006"),
            filters = "ensembl_gene_id",
            values = genes,
            mart = ensembl)

Combine annotations per gene

basic_gene <- basic %>% arrange(ensembl_gene_id)
pheno_gene <- pheno %>% group_by(ensembl_gene_id) %>%
  summarize(phenotype = paste(phenotype_description, collapse = ";")) %>%
  arrange(ensembl_gene_id)
`summarise()` ungrouping output (override with `.groups` argument)
stopifnot(basic_gene$ensembl_gene_id == pheno_gene$ensembl_gene_id)
basic_pheno <- cbind(basic_gene, pheno_gene[, "phenotype"])

go_gene <- go %>% group_by(ensembl_gene_id) %>%
  summarize(go_id = paste(go_id, collapse = ";"),
            go_descrip = paste(name_1006, collapse = ";")) %>%
  arrange(ensembl_gene_id)
`summarise()` ungrouping output (override with `.groups` argument)
combined <- merge(basic_pheno, go_gene, by = "ensembl_gene_id",
                  sort = TRUE, all.x = TRUE)
stopifnot(sort(genes) == combined$ensembl_gene_id)

Save gene annotations

write.table(combined, file.path("data/gene-annotation.txt"),
            quote = FALSE, sep = "\t", row.names = FALSE)

sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Catalina 10.15.7

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] dplyr_1.0.2    biomaRt_2.40.5

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.5             pillar_1.4.6           compiler_3.6.3        
 [4] later_1.1.0.1          git2r_0.27.1           workflowr_1.6.2       
 [7] prettyunits_1.1.1      progress_1.2.2         bitops_1.0-6          
[10] tools_3.6.3            bit_4.0.4              digest_0.6.25         
[13] memoise_1.1.0          evaluate_0.14          RSQLite_2.2.0         
[16] lifecycle_0.2.0        tibble_3.0.3           pkgconfig_2.0.3       
[19] rlang_0.4.7            DBI_1.1.0              rstudioapi_0.11.0-9000
[22] curl_4.3               parallel_3.6.3         yaml_2.2.1            
[25] xfun_0.16              httr_1.4.2             stringr_1.4.0         
[28] knitr_1.29             generics_0.0.2         hms_0.5.3             
[31] IRanges_2.18.3         S4Vectors_0.22.1       fs_1.5.0              
[34] vctrs_0.3.4            tidyselect_1.1.0       stats4_3.6.3          
[37] rprojroot_1.3-2        bit64_4.0.5            Biobase_2.44.0        
[40] glue_1.4.2             R6_2.4.1               AnnotationDbi_1.46.1  
[43] XML_3.98-1.20          rmarkdown_2.3          purrr_0.3.4           
[46] blob_1.2.1             magrittr_1.5           whisker_0.4           
[49] BiocGenerics_0.30.0    backports_1.1.9        promises_1.1.1        
[52] ellipsis_0.3.1         htmltools_0.5.0        httpuv_1.5.4          
[55] stringi_1.4.6          RCurl_1.98-1.2         crayon_1.3.4