Last updated: 2020-04-28
Checks: 7 0
Knit directory: BgeeCall_practical/
This reproducible R Markdown analysis was created with workflowr (version 1.6.1). 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(20200421) 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 3bcbb2e. 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: analysis/figure/
Untracked files:
Untracked: PCA_dim_1vs2.png
Untracked: PCA_prop_explained_variance.png
Untracked: analyis.R
Untracked: dif_expressed_genes.tsv
Untracked: inputFile.tsv
Untracked: input_files/
Untracked: merge.R
Untracked: output_files/
Untracked: release.tsv
Unstaged changes:
Deleted: analysis/exercices.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/analysis.Rmd) and HTML (docs/analysis.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 | dc40200 | Julien | 2020-04-28 | Build site. |
| html | 1f5ab18 | Julien | 2020-04-27 | Build site. |
| Rmd | f9a3dfa | Julien | 2020-04-27 | wflow_publish(“analysis/analysis.Rmd”) |
| html | f01becc | Julien | 2020-04-25 | Build site. |
| Rmd | 1e84e4a | Julien | 2020-04-25 | wflow_publish(files = c(“analysis/analysis.Rmd”, “analysis/classes_description.Rmd”, |
| Rmd | 625ed05 | Julien | 2020-04-24 | wflow_publish(files = c(“analysis/analysis.Rmd”, “analysis/classes_description.Rmd”, |
| html | 3f5d76c | Julien | 2020-04-24 | Build site. |
| html | 64f7db8 | Julien | 2020-04-24 | Build site. |
| Rmd | 590e07d | Julien | 2020-04-24 | wflow_publish(files = c(“analysis/analysis.Rmd”, “analysis/classes_description.Rmd”, |
| html | 2c7601e | Julien | 2020-04-24 | Build site. |
| Rmd | 6da0a8d | Julien | 2020-04-24 | wflow_publish(files = c(“analysis/analysis.Rmd”, “analysis/classes_description.Rmd”, |
| html | d93bad7 | Julien | 2020-04-22 | update all html files |
| Rmd | 454071e | Julien | 2020-04-22 | create backbone of the website |
| html | 454071e | Julien | 2020-04-22 | create backbone of the website |
Once BgeeCall generated gene experssion calls it is possible to use them to do downstream analysis. This section contains R code examples of potential analysis to run on present genes.
# read file with gene as rows and libraries as columns
file <- "PATH_TO_PRESENT_TPMS_FILE"
present_TPMs <- read.table(file = file, header = TRUE, sep = "\t")
# transpose data.frame to have genes as columns
data_for_PCA <- t(present_TPMs)
# calculate matrix of dissimilarities
# k = the maximum dimension of the space which the data are to be represented in; must be in {1, 2, …, n-1}
# eig = indicates whether eigenvalues should be returned
mds <- cmdscale(dist(data_for_PCA), k=3, eig=TRUE)
proportion_eig <- mds$eig * 100 / sum(mds$eig)
# plot proportion of variance explained by each dimension
barplot(proportion_eig, las=1, ylim=c(0,100), xlab="Dimensions", ylab="Proportion of explained variance (%)",
y.axis=NULL, col="darkgrey", main = "Proportion of variance explained by each dimension")

#PCA plot for the 2 first dimensions
#plotMDS(present_TPMs,xlab = "Dimension 1")
plot(mds$points[,1], -mds$points[,2], type="n", xlim=c(-2.5e+05,2.5e+05), xlab="Dimension 1", ylab="Dimension 2",
main="PCA plot of the 2 principal dimensions", )
text(mds$points[,1], -mds$points[,2], rownames(mds$points), cex=0.8)

library(edgeR)
Loading required package: limma
# read file with gene as rows and libraries counts as columns
file_counts <- "PATH_TO_PRESENT_COUNTS_FILE"
present_counts <- read.table(file = file_counts, header = TRUE, sep = "\t")
#read file with library annotations
file_annotations <- "PATH_TO_LIBRARY_ANNOTATIONS_FILE"
library_annotations <- read.table(file = file_annotations, header = TRUE, sep = "\t")
# create list of grouping parameters (here sex)
group <- NULL
for(i in seq(colnames(present_counts))){
group[i] <- as.character(library_annotations[library_annotations$Library.ID ==colnames(present_counts)[i],]$Sex)
}
# create DGEList object
dge <- DGEList(present_counts, group=group)
#calculate normalization factor between libraries
dge <- calcNormFactors(dge)
#estimate common and tag wise dispersion
dge <- estimateCommonDisp(dge)
dge <- estimateTagwiseDisp(dge)
#perform an exact test for the difference in expression male-female
dgeTest <- exactTest(dge)
# retrieve all gene differentially expressed with a p-value lower than 0.05
topTags <- topTags(dgeTest, n=nrow(dgeTest$table), p.value = 0.05)
#filter for FDR < 0.05
results <- topTags$table[topTags$table$FDR<0.05,]
write.table(x = results, file = "dif_expressed_genes.tsv", row.names = TRUE, quote = FALSE, sep="\t")
# generate an MA plot with 1% differentially expressed genes
plotSmear(dgeTest, de.tags = rownames(topTags$table)[which(topTags$table$FDR<0.01)],)

# generate a volcano plot
volcanoData <- cbind(topTags$table$logFC, -log10(topTags$table$PValue))
colnames(volcanoData) <- c("logFC", "negLogPval")
plot(volcanoData, pch=19)

library(biomaRt)
## topGO function of edgeR require entrez IDs. We will use biomaRt to map ensembl Ids to entrez Ids
#query biomaRt
mart <- useDataset("dmelanogaster_gene_ensembl", useMart("ensembl"))
entrez_mapping <- getBM(attributes=c("ensembl_gene_id", "entrezgene_id"), mart=mart, useCache = FALSE)
#update row names of the DGEExact object from edgeR
table <- merge(dgeTest$table, entrez_mapping, by.x="row.names", by.y="ensembl_gene_id", all.x = TRUE)
#looks like mapping from biomaRt has some problems of redundancy. Need hack to remove redundancy (not good practice)
table <- na.omit(table[!duplicated(table[,c('entrezgene_id')]),])
rownames(table) <- table$entrezgene_id
dgeTest$table <- table[,c('logFC','logCPM','PValue')]
#run the GO analysis
go <- goana(dgeTest, species = "Dm")
topGO(go)
Term Ont N Up Down P.Up
GO:0022626 cytosolic ribosome CC 91 0 86 1.0000000
GO:0002181 cytoplasmic translation BP 117 0 94 1.0000000
GO:0042254 ribosome biogenesis BP 191 3 123 1.0000000
GO:0022613 ribonucleoprotein complex biogenesis BP 268 6 138 1.0000000
GO:0044445 cytosolic part CC 143 6 93 0.9999738
GO:0022625 cytosolic large ribosomal subunit CC 52 0 51 1.0000000
GO:0006364 rRNA processing BP 124 3 80 0.9999985
GO:0005840 ribosome CC 174 4 96 1.0000000
GO:0016072 rRNA metabolic process BP 142 4 85 0.9999990
GO:0044391 ribosomal subunit CC 165 3 92 1.0000000
GO:0006412 translation BP 367 9 151 1.0000000
GO:0043604 amide biosynthetic process BP 425 16 166 1.0000000
GO:0043043 peptide biosynthetic process BP 401 12 159 1.0000000
GO:1990904 ribonucleoprotein complex CC 556 26 197 1.0000000
GO:0005730 nucleolus CC 185 6 95 0.9999999
GO:0043603 cellular amide metabolic process BP 526 30 186 1.0000000
GO:0003735 structural constituent of ribosome MF 158 4 86 0.9999999
GO:0006518 peptide metabolic process BP 464 23 168 1.0000000
GO:0042273 ribosomal large subunit biogenesis BP 51 0 43 1.0000000
GO:0022627 cytosolic small ribosomal subunit CC 38 0 36 1.0000000
P.Down
GO:0022626 1.966044e-62
GO:0002181 9.423063e-54
GO:0042254 4.884838e-52
GO:0022613 3.330418e-42
GO:0044445 5.653007e-40
GO:0022625 9.007390e-40
GO:0006364 4.019224e-34
GO:0005840 1.061884e-32
GO:0016072 1.223935e-32
GO:0044391 7.403915e-32
GO:0006412 1.165862e-31
GO:0043604 1.531185e-31
GO:0043043 4.264480e-31
GO:1990904 1.069313e-30
GO:0005730 4.486529e-29
GO:0043603 7.974862e-29
GO:0003735 8.356819e-29
GO:0006518 2.293887e-27
GO:0042273 9.169436e-27
GO:0022627 1.126329e-26
sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.4 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so
locale:
[1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C
[3] LC_TIME=fr_FR.UTF-8 LC_COLLATE=en_GB.UTF-8
[5] LC_MONETARY=fr_FR.UTF-8 LC_MESSAGES=en_GB.UTF-8
[7] LC_PAPER=fr_FR.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] biomaRt_2.42.0 edgeR_3.28.1 limma_3.42.2 workflowr_1.6.1
loaded via a namespace (and not attached):
[1] progress_1.2.2 locfit_1.5-9.4 tidyselect_1.0.0
[4] xfun_0.12 purrr_0.3.3 lattice_0.20-41
[7] vctrs_0.2.3 htmltools_0.4.0 stats4_3.6.3
[10] BiocFileCache_1.10.2 yaml_2.2.1 blob_1.2.1
[13] XML_3.99-0.3 rlang_0.4.5 later_1.0.0
[16] pillar_1.4.3 glue_1.3.1 DBI_1.1.0
[19] rappdirs_0.3.1 BiocGenerics_0.32.0 bit64_0.9-7
[22] dbplyr_1.4.2 stringr_1.4.0 memoise_1.1.0
[25] evaluate_0.14 Biobase_2.46.0 knitr_1.28
[28] IRanges_2.20.2 httpuv_1.5.2 curl_4.3
[31] parallel_3.6.3 AnnotationDbi_1.48.0 Rcpp_1.0.3
[34] openssl_1.4.1 promises_1.1.0 backports_1.1.5
[37] S4Vectors_0.24.3 fs_1.3.2 bit_1.1-15.2
[40] hms_0.5.3 askpass_1.1 digest_0.6.25
[43] stringi_1.4.6 dplyr_0.8.4 grid_3.6.3
[46] rprojroot_1.3-2 tools_3.6.3 magrittr_1.5
[49] RSQLite_2.2.0 tibble_2.1.3 GO.db_3.10.0
[52] crayon_1.3.4 whisker_0.4 pkgconfig_2.0.3
[55] prettyunits_1.1.1 org.Dm.eg.db_3.10.0 assertthat_0.2.1
[58] rmarkdown_2.1 httr_1.4.1 R6_2.4.1
[61] git2r_0.26.1 compiler_3.6.3