-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added sorting for Sample names to avoid conflicts * Clean * Added rule to annotate ensemblID with gene symbol * fmt * added env * Update deseq2-init.R * more variable test data * more variable test data Co-authored-by: jafors <[email protected]>
- Loading branch information
Showing
8 changed files
with
103 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
sample_name condition | ||
A treated | ||
B untreated | ||
A1 treated | ||
B1 untreated | ||
A2 treated | ||
B2 untreated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
sample_name unit_name fq1 fq2 sra adapters strandedness | ||
A1 1 ngs-test-data/reads/a.scerevisiae.1.fq ngs-test-data/reads/a.scerevisiae.2.fq | ||
B1 1 ngs-test-data/reads/c.scerevisiae.1.fq ngs-test-data/reads/c.scerevisiae.2.fq | ||
A2 1 ngs-test-data/reads/a.scerevisiae.1.fq ngs-test-data/reads/a.scerevisiae.2.fq | ||
B2 1 ngs-test-data/reads/c.scerevisiae.1.fq ngs-test-data/reads/c.scerevisiae.2.fq | ||
A2 1 ngs-test-data/reads/c.scerevisiae.1.fq ngs-test-data/reads/c.scerevisiae.2.fq | ||
B2 1 ngs-test-data/reads/b.scerevisiae.1.fq ngs-test-data/reads/b.scerevisiae.2.fq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
channels: | ||
- bioconda | ||
- conda-forge | ||
dependencies: | ||
- bioconductor-biomart =2.46 | ||
- r-tidyverse =1.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
library(biomaRt) | ||
library(tidyverse) | ||
|
||
# this variable holds a mirror name until | ||
# useEnsembl succeeds ("www" is last, because | ||
# of very frequent "Internal Server Error"s) | ||
mart <- "useast" | ||
rounds <- 0 | ||
while ( class(mart)[[1]] != "Mart" ) { | ||
mart <- tryCatch( | ||
{ | ||
# done here, because error function does not | ||
# modify outer scope variables, I tried | ||
if (mart == "www") rounds <- rounds + 1 | ||
# equivalent to useMart, but you can choose | ||
# the mirror instead of specifying a host | ||
biomaRt::useEnsembl( | ||
biomart = "ENSEMBL_MART_ENSEMBL", | ||
dataset = str_c(snakemake@params[["species"]], "_gene_ensembl"), | ||
mirror = mart | ||
) | ||
}, | ||
error = function(e) { | ||
# change or make configurable if you want more or | ||
# less rounds of tries of all the mirrors | ||
if (rounds >= 3) { | ||
stop( | ||
) | ||
} | ||
# hop to next mirror | ||
mart <- switch(mart, | ||
useast = "uswest", | ||
uswest = "asia", | ||
asia = "www", | ||
www = { | ||
# wait before starting another round through the mirrors, | ||
# hoping that intermittent problems disappear | ||
Sys.sleep(30) | ||
"useast" | ||
} | ||
) | ||
} | ||
) | ||
} | ||
|
||
|
||
df <- read.table(snakemake@input[["counts"]], sep='\t', header=1) | ||
|
||
g2g <- biomaRt::getBM( | ||
attributes = c( "ensembl_gene_id", | ||
"external_gene_name"), | ||
filters = "ensembl_gene_id", | ||
values = df$gene, | ||
mart = mart, | ||
) | ||
|
||
annotated <- merge(df, g2g, by.x="gene", by.y="ensembl_gene_id") | ||
annotated$gene <- ifelse(annotated$external_gene_name == '', annotated$gene, annotated$external_gene_name) | ||
annotated$external_gene_name <- NULL | ||
write.table(annotated, snakemake@output[["symbol"]], sep='\t', row.names=F) | ||
|
||
|