Last updated: 2020-04-24
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 6da0a8d. 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/
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: merge.R
Untracked: release.tsv
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 |
|---|---|---|---|---|
| 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 |
This section present R code of downstream analysis that can be done using genes with presence of expression.
# read file with gene as rows and libraries as columns
file <- "/cloud/project/input_files/downstream_analysis/present_TPMs.tsv"
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
png(file="PCA_prop_explained_variance.png")
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")
dev.off()
# calculate matrix of dissimilarities
mds <- cmdscale(dist(data_for_PCA))
#PCA plot for the 2 first dimensions
png(file="PCA_dim_1vs2.png")
plot(mds[,1], -mds[,2], type="n", xlim=c(-1.5e+05,1.5e+05), xlab="Dimension 1", ylab="Dimension 2",
main="PCA plot of the 2 principal dimensions")
text(mds[,1], -mds[,2], rownames(mds), cex=0.8)
dev.off()
# load required libraries
library(edgeR)
Loading required package: limma
# read file with gene as rows and libraries counts as columns
file_counts <- "../../temp/test_bgeeCall/output/7227/present_counts.tsv"
present_counts <- read.table(file = file_counts, header = TRUE, sep = "\t")
genes <- rownames(present_counts)
#read file with library annotations
file_annotations <- "../../temp/test_bgeeCall/output/7227/library_annotations.tsv"
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)
}
# use group as names of the present_count data.frame
colnames(present_counts) <- group
# create the design matrix for limma
design_matrix <- model.matrix(~0+group)
colnames(design_matrix)<- gsub("group","",colnames(design_matrix))
# calculate the normalization factors between libraries
normalization_factors <- calcNormFactors(present_counts)
# use voom to calculate normalised read counts
voom_output <- voom(present_counts,design_matrix,lib.size=colSums(present_counts)*normalization_factors)
# extract the normalised read counts
normalised_counts <- voom_output$E
# fit linear model for each gene given a series of libraries
fit <- lmFit(voom_output, design_matrix)
# construct the contrast matrix corresponding to specified contrasts of a set of parameters
cont.matrix <- makeContrasts(male-female,levels=design_matrix)
# compute estimated coefficients and standard errors for a given set of contrasts
fit <- contrasts.fit(fit, cont.matrix)
# compute moderated t-statistics of differential expression by empirical Bayes moderation of the standard errors
fit <- eBayes(fit)
options(digits=3)
# use the topTable function to order genes and filter by p-value and log fold change
results <- topTable(fit, coef="male - female", number = nrow(present_counts), p.value = 0.05, lfc = 2)
#write differentialy expressed genes in a file
#write.table(x = results, file = "/cloud/project/output_files/dif_expressed_genes.tsv", row.names = TRUE, quote = FALSE, sep="\t")
write.table(x = results, file = "dif_expressed_genes.tsv", row.names = TRUE, quote = FALSE, sep="\t")
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] edgeR_3.28.1 limma_3.42.2 workflowr_1.6.1
loaded via a namespace (and not attached):
[1] Rcpp_1.0.3 knitr_1.28 whisker_0.4 magrittr_1.5
[5] lattice_0.20-41 R6_2.4.1 rlang_0.4.5 stringr_1.4.0
[9] tools_3.6.3 grid_3.6.3 xfun_0.12 git2r_0.26.1
[13] htmltools_0.4.0 yaml_2.2.1 digest_0.6.25 rprojroot_1.3-2
[17] later_1.0.0 promises_1.1.0 fs_1.3.2 glue_1.3.1
[21] evaluate_0.14 rmarkdown_2.1 stringi_1.4.6 compiler_3.6.3
[25] backports_1.1.5 locfit_1.5-9.4 httpuv_1.5.2