Skip to content

Commit 1573c4d

Browse files
authored
Merge pull request #707 from ARTbio/gsc_gene_expr_corr
Update gsc_gene_expression_correlation
2 parents 023776e + 5151cde commit 1573c4d

File tree

3 files changed

+91
-83
lines changed

3 files changed

+91
-83
lines changed

Diff for: tools/gsc_gene_expression_correlations/.shed.yml

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ long_description: |
77
between genes and a signature of selected genes.
88
categories:
99
- Transcriptomics
10+
- Single Cell
1011
homepage_url: http://artbio.fr
1112
remote_repository_url: https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_gene_expression_correlations
1213
toolshed:

Diff for: tools/gsc_gene_expression_correlations/correlation_with_signature.R

+86-82
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
# --gene_corr_pval <gene-gene corr pvalues file>
1111
# --sig_corr <genes correlation to signature file>
1212

13-
options(show.error.messages = FALSE,
14-
error = function() {
15-
cat(geterrmessage(), file = stderr())
16-
q("no", 1, FALSE)
17-
}
13+
options(
14+
show.error.messages = FALSE,
15+
error = function() {
16+
cat(geterrmessage(), file = stderr())
17+
q("no", 1, FALSE)
18+
}
1819
)
1920
loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
2021

@@ -23,75 +24,76 @@ library(Hmisc)
2324

2425
# Arguments
2526
option_list <- list(
26-
make_option(
27-
"--sep",
28-
default = "\t",
29-
type = "character",
30-
help = "File separator, must be the same for all input files [default : '%default' ]"
31-
),
32-
make_option(
33-
"--colnames",
34-
default = TRUE,
35-
type = "logical",
36-
help = "Consider first lines as header (must stand for all input files) [default : '%default' ]"
37-
),
38-
make_option(
39-
"--expression_file",
40-
default = NA,
41-
type = "character",
42-
help = "Input file that contains log2(CPM +1) expression values"
43-
),
44-
make_option(
45-
"--signatures_file",
46-
default = NA,
47-
type = "character",
48-
help = "Input file that contains cell signature"
49-
),
50-
make_option(
51-
"--sig_corr",
52-
default = "sig_corr.tsv",
53-
type = "character",
54-
help = "signature correlations output [default : '%default' ]"
55-
),
56-
make_option(
57-
"--gene_corr",
58-
default = "gene_corr.tsv",
59-
type = "character",
60-
help = "genes-genes correlations output [default : '%default' ]"
61-
),
62-
make_option(
63-
"--gene_corr_pval",
64-
default = "gene_corr_pval.tsv",
65-
type = "character",
66-
help = "genes-genes correlations pvalues output [default : '%default' ]"
67-
)
27+
make_option(
28+
"--sep",
29+
default = "\t",
30+
type = "character",
31+
help = "File separator, must be the same for all input files [default : '%default' ]"
32+
),
33+
make_option(
34+
"--colnames",
35+
default = TRUE,
36+
type = "logical",
37+
help = "Consider first lines as header (must stand for all input files) [default : '%default' ]"
38+
),
39+
make_option(
40+
"--expression_file",
41+
default = NA,
42+
type = "character",
43+
help = "Input file that contains log2(CPM +1) expression values"
44+
),
45+
make_option(
46+
"--signatures_file",
47+
default = NA,
48+
type = "character",
49+
help = "Input file that contains cell signature"
50+
),
51+
make_option(
52+
"--sig_corr",
53+
default = "sig_corr.tsv",
54+
type = "character",
55+
help = "signature correlations output [default : '%default' ]"
56+
),
57+
make_option(
58+
"--gene_corr",
59+
default = "gene_corr.tsv",
60+
type = "character",
61+
help = "genes-genes correlations output [default : '%default' ]"
62+
),
63+
make_option(
64+
"--gene_corr_pval",
65+
default = "gene_corr_pval.tsv",
66+
type = "character",
67+
help = "genes-genes correlations pvalues output [default : '%default' ]"
68+
)
6869
)
6970

7071
opt <- parse_args(OptionParser(option_list = option_list),
71-
args = commandArgs(trailingOnly = TRUE))
72+
args = commandArgs(trailingOnly = TRUE)
73+
)
7274

7375
if (opt$sep == "tab") {
74-
opt$sep <- "\t"
76+
opt$sep <- "\t"
7577
}
7678
if (opt$sep == "comma") {
77-
opt$sep <- ","
79+
opt$sep <- ","
7880
}
7981

8082
# Open files
8183
data <- read.delim(
82-
opt$expression_file,
83-
header = opt$colnames,
84-
row.names = 1,
85-
sep = opt$sep,
86-
check.names = FALSE
84+
opt$expression_file,
85+
header = opt$colnames,
86+
row.names = 1,
87+
sep = opt$sep,
88+
check.names = FALSE
8789
)
8890
signature <- read.delim(
89-
opt$signatures_file,
90-
header = TRUE,
91-
stringsAsFactors = FALSE,
92-
row.names = 1,
93-
sep = opt$sep,
94-
check.names = FALSE
91+
opt$signatures_file,
92+
header = TRUE,
93+
stringsAsFactors = FALSE,
94+
row.names = 1,
95+
sep = opt$sep,
96+
check.names = FALSE
9597
)
9698

9799

@@ -105,39 +107,41 @@ data <- rbind(t(signature), data)
105107
gene_corr <- rcorr(t(data), type = "pearson") # transpose because we correlate genes, not cells
106108

107109
# Gene correlation with signature score
108-
gene_signature_corr <- cbind.data.frame(gene = colnames(gene_corr$r),
109-
Pearson_correlation = gene_corr$r[, 1],
110-
p_value = gene_corr$P[, 1])
110+
gene_signature_corr <- cbind.data.frame(
111+
gene = colnames(gene_corr$r),
112+
Pearson_correlation = gene_corr$r[, 1],
113+
p_value = gene_corr$P[, 1]
114+
)
111115
gene_signature_corr <- gene_signature_corr[order(gene_signature_corr[, 2], decreasing = TRUE), ]
112116

113117

114118
### Save files ###
115119

116120
write.table(
117-
format(gene_signature_corr, digits = 2),
118-
file = opt$sig_corr,
119-
sep = "\t",
120-
quote = FALSE,
121-
col.names = TRUE,
122-
row.names = FALSE
121+
format(gene_signature_corr, digits = 2),
122+
file = opt$sig_corr,
123+
sep = "\t",
124+
quote = FALSE,
125+
col.names = TRUE,
126+
row.names = FALSE
123127
)
124128

125129
r_genes <- data.frame(gene = rownames(gene_corr$r), gene_corr$r) # add rownames as a variable for output
126130
write.table(
127-
format(r_genes[-1, -2], digits = 2),
128-
file = opt$gene_corr,
129-
sep = "\t",
130-
quote = FALSE,
131-
col.names = TRUE,
132-
row.names = FALSE
131+
format(r_genes[-1, -2], digits = 2),
132+
file = opt$gene_corr,
133+
sep = "\t",
134+
quote = FALSE,
135+
col.names = TRUE,
136+
row.names = FALSE
133137
)
134138

135139
p_genes <- data.frame(gene = rownames(gene_corr$P), gene_corr$P) # add rownames as a variable for output
136140
write.table(
137-
format(p_genes[-1, -2], digits = 2),
138-
file = opt$gene_corr_pval,
139-
sep = "\t",
140-
quote = FALSE,
141-
col.names = TRUE,
142-
row.names = FALSE
141+
format(p_genes[-1, -2], digits = 2),
142+
file = opt$gene_corr_pval,
143+
sep = "\t",
144+
quote = FALSE,
145+
col.names = TRUE,
146+
row.names = FALSE
143147
)

Diff for: tools/gsc_gene_expression_correlations/correlation_with_signature.xml

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
<tool id="single_cell_gene_expression_correlations" name="single-cell gene expression correlations" version="4.3.1+galaxy0" profile="21.01">
1+
<tool id="single_cell_gene_expression_correlations" name="single-cell gene expression correlations" version="4.3.1+galaxy1" profile="21.01">
22
<description>between genes or with a signature of selected genes</description>
3+
<xrefs>
4+
<xref type="bio.tools">galaxy_single_cell_suite</xref>
5+
</xrefs>
36
<requirements>
47
<requirement type="package" version="1.7.3">r-optparse</requirement>
58
<requirement type="package" version="5.1_1">r-hmisc</requirement>

0 commit comments

Comments
 (0)