biopipen 0.28.1__py3-none-any.whl → 0.29.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of biopipen might be problematic. Click here for more details.
- biopipen/__init__.py +1 -1
- biopipen/core/config.toml +8 -0
- biopipen/ns/bam.py +0 -2
- biopipen/ns/bed.py +35 -0
- biopipen/ns/cellranger_pipeline.py +5 -5
- biopipen/ns/cnv.py +18 -2
- biopipen/ns/cnvkit_pipeline.py +16 -11
- biopipen/ns/gene.py +68 -23
- biopipen/ns/misc.py +2 -15
- biopipen/ns/plot.py +204 -0
- biopipen/ns/regulatory.py +214 -0
- biopipen/ns/scrna.py +31 -5
- biopipen/ns/snp.py +516 -8
- biopipen/ns/stats.py +167 -3
- biopipen/ns/vcf.py +196 -0
- biopipen/reports/snp/PlinkCallRate.svelte +24 -0
- biopipen/reports/snp/PlinkFreq.svelte +18 -0
- biopipen/reports/snp/PlinkHWE.svelte +18 -0
- biopipen/reports/snp/PlinkHet.svelte +18 -0
- biopipen/reports/snp/PlinkIBD.svelte +18 -0
- biopipen/scripts/bam/CNVpytor.py +144 -46
- biopipen/scripts/bed/BedtoolsIntersect.py +54 -0
- biopipen/scripts/bed/BedtoolsMerge.py +1 -1
- biopipen/scripts/cnv/AneuploidyScore.R +30 -7
- biopipen/scripts/cnv/AneuploidyScoreSummary.R +5 -2
- biopipen/scripts/cnv/TMADScore.R +21 -5
- biopipen/scripts/cnv/TMADScoreSummary.R +6 -2
- biopipen/scripts/cnvkit/CNVkitAccess.py +2 -1
- biopipen/scripts/cnvkit/CNVkitAutobin.py +3 -2
- biopipen/scripts/cnvkit/CNVkitBatch.py +1 -1
- biopipen/scripts/cnvkit/CNVkitCoverage.py +2 -1
- biopipen/scripts/cnvkit/CNVkitGuessBaits.py +1 -1
- biopipen/scripts/cnvkit/CNVkitHeatmap.py +1 -1
- biopipen/scripts/cnvkit/CNVkitReference.py +2 -1
- biopipen/scripts/delim/SampleInfo.R +10 -5
- biopipen/scripts/gene/GeneNameConversion.R +65 -0
- biopipen/scripts/gene/GenePromoters.R +61 -0
- biopipen/scripts/misc/Shell.sh +15 -0
- biopipen/scripts/plot/Manhattan.R +146 -0
- biopipen/scripts/plot/QQPlot.R +146 -0
- biopipen/scripts/regulatory/MotifAffinityTest.R +226 -0
- biopipen/scripts/regulatory/MotifAffinityTest_AtSNP.R +126 -0
- biopipen/scripts/regulatory/MotifAffinityTest_MotifBreakR.R +96 -0
- biopipen/scripts/regulatory/MotifScan.py +159 -0
- biopipen/scripts/regulatory/atSNP.R +33 -0
- biopipen/scripts/regulatory/motifBreakR.R +1594 -0
- biopipen/scripts/scrna/MarkersFinder.R +69 -67
- biopipen/scripts/scrna/SeuratClustering.R +71 -29
- biopipen/scripts/scrna/SeuratMap2Ref.R +20 -0
- biopipen/scripts/scrna/SeuratPreparing.R +252 -122
- biopipen/scripts/scrna/SeuratSubClustering.R +76 -27
- biopipen/scripts/snp/MatrixEQTL.R +85 -44
- biopipen/scripts/snp/Plink2GTMat.py +133 -0
- biopipen/scripts/snp/PlinkCallRate.R +190 -0
- biopipen/scripts/snp/PlinkFilter.py +100 -0
- biopipen/scripts/snp/PlinkFreq.R +298 -0
- biopipen/scripts/snp/PlinkFromVcf.py +78 -0
- biopipen/scripts/snp/PlinkHWE.R +80 -0
- biopipen/scripts/snp/PlinkHet.R +92 -0
- biopipen/scripts/snp/PlinkIBD.R +200 -0
- biopipen/scripts/snp/PlinkUpdateName.py +124 -0
- biopipen/scripts/stats/Mediation.R +94 -0
- biopipen/scripts/stats/MetaPvalue.R +2 -1
- biopipen/scripts/stats/MetaPvalue1.R +70 -0
- biopipen/scripts/tcr/TCRClusterStats.R +12 -7
- biopipen/scripts/vcf/BcftoolsAnnotate.py +91 -0
- biopipen/scripts/vcf/BcftoolsFilter.py +90 -0
- biopipen/scripts/vcf/BcftoolsSort.py +113 -0
- biopipen/scripts/vcf/BcftoolsView.py +73 -0
- biopipen/scripts/vcf/VcfFix_utils.py +1 -1
- biopipen/scripts/vcf/bcftools_utils.py +52 -0
- biopipen/utils/gene.R +83 -37
- biopipen/utils/gene.py +108 -60
- biopipen/utils/misc.R +56 -0
- biopipen/utils/misc.py +5 -2
- biopipen/utils/reference.py +54 -10
- {biopipen-0.28.1.dist-info → biopipen-0.29.1.dist-info}/METADATA +2 -2
- {biopipen-0.28.1.dist-info → biopipen-0.29.1.dist-info}/RECORD +80 -51
- {biopipen-0.28.1.dist-info → biopipen-0.29.1.dist-info}/entry_points.txt +1 -1
- biopipen/ns/bcftools.py +0 -111
- biopipen/scripts/bcftools/BcftoolsAnnotate.py +0 -42
- biopipen/scripts/bcftools/BcftoolsFilter.py +0 -79
- biopipen/scripts/bcftools/BcftoolsSort.py +0 -19
- biopipen/scripts/gene/GeneNameConversion.py +0 -66
- {biopipen-0.28.1.dist-info → biopipen-0.29.1.dist-info}/WHEEL +0 -0
biopipen/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.
|
|
1
|
+
__version__ = "0.29.1"
|
biopipen/core/config.toml
CHANGED
|
@@ -23,12 +23,16 @@ cnvpytor = "cnvpytor"
|
|
|
23
23
|
cnvnator2vcf = "cnvnator2VCF.pl"
|
|
24
24
|
# convert
|
|
25
25
|
convert = "convert"
|
|
26
|
+
# fimo from meme
|
|
27
|
+
fimo = "fimo"
|
|
26
28
|
# wget
|
|
27
29
|
wget = "wget"
|
|
28
30
|
# aria2c
|
|
29
31
|
aria2c = "aria2c"
|
|
30
32
|
# plink
|
|
31
33
|
plink = "plink"
|
|
34
|
+
# plink2
|
|
35
|
+
plink2 = "plink2"
|
|
32
36
|
# tabix
|
|
33
37
|
tabix = "tabix"
|
|
34
38
|
# sambamba
|
|
@@ -86,6 +90,10 @@ genome = ""
|
|
|
86
90
|
# Database file for scType
|
|
87
91
|
# https://github.com/IanevskiAleksandr/sc-type/
|
|
88
92
|
sctype_db = ""
|
|
93
|
+
# TF Motif database
|
|
94
|
+
tf_motifdb = ""
|
|
95
|
+
# TF motif pairs
|
|
96
|
+
tf_motifs = ""
|
|
89
97
|
|
|
90
98
|
[misc]
|
|
91
99
|
# Number of cores used for each job
|
biopipen/ns/bam.py
CHANGED
|
@@ -17,7 +17,6 @@ class CNVpytor(Proc):
|
|
|
17
17
|
|
|
18
18
|
Envs:
|
|
19
19
|
cnvpytor: Path to cnvpytor
|
|
20
|
-
cnvnator2vcf: Path to CNVnator2VCF.pl to convert the result to VCF file
|
|
21
20
|
samtools: Path to samtools, used to index bam file in case it's not
|
|
22
21
|
ncores: Number of cores to use (`-j` for cnvpytor)
|
|
23
22
|
refdir: The directory containing the fasta file for each chromosome
|
|
@@ -41,7 +40,6 @@ class CNVpytor(Proc):
|
|
|
41
40
|
lang = config.lang.python
|
|
42
41
|
envs = {
|
|
43
42
|
"cnvpytor": config.exe.cnvpytor,
|
|
44
|
-
"cnvnator2vcf": config.exe.cnvnator2vcf,
|
|
45
43
|
"samtools": config.exe.samtools,
|
|
46
44
|
"ncores": config.misc.ncores,
|
|
47
45
|
"refdir": config.ref.refdir,
|
biopipen/ns/bed.py
CHANGED
|
@@ -163,3 +163,38 @@ class BedtoolsMerge(Proc):
|
|
|
163
163
|
"bedtools": config.exe.bedtools,
|
|
164
164
|
}
|
|
165
165
|
script = "file://../scripts/bed/BedtoolsMerge.py"
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
class BedtoolsIntersect(Proc):
|
|
169
|
+
"""Find the intersection of two BED files, using `bedtools intersect`
|
|
170
|
+
|
|
171
|
+
See <https://bedtools.readthedocs.io/en/latest/content/tools/intersect.html>
|
|
172
|
+
|
|
173
|
+
Input:
|
|
174
|
+
afile: The first BED file
|
|
175
|
+
bfile: The second BED file
|
|
176
|
+
|
|
177
|
+
Output:
|
|
178
|
+
outfile: The output BED file
|
|
179
|
+
|
|
180
|
+
Envs:
|
|
181
|
+
bedtools: The path to bedtools
|
|
182
|
+
sort: Sort `afile` and `bfile` before intersecting.
|
|
183
|
+
By default, `-sorted` is used, assuming the input files are sorted.
|
|
184
|
+
If error occurs, try to set `sort` to `True`.
|
|
185
|
+
chrsize: Alias for `g` in `bedtools intersect`.
|
|
186
|
+
postcmd: The command to be executed for the output file after intersecting.
|
|
187
|
+
You can use `$infile`, `$outfile`, and `$outdir` to refer to the input,
|
|
188
|
+
output, and output directory, respectively.
|
|
189
|
+
<more>: Other options to be passed to `bedtools intersect`
|
|
190
|
+
""" # noqa: E501
|
|
191
|
+
input = "afile:file", "bfile:file"
|
|
192
|
+
output = "outfile:file:{{in.afile | stem0}}_{{in.bfile | stem0}}-intersect.bt"
|
|
193
|
+
lang = config.lang.python
|
|
194
|
+
envs = {
|
|
195
|
+
"bedtools": config.exe.bedtools,
|
|
196
|
+
"sort": False,
|
|
197
|
+
"chrsize": config.ref.chrsize,
|
|
198
|
+
"postcmd": None,
|
|
199
|
+
}
|
|
200
|
+
script = "file://../scripts/bed/BedtoolsIntersect.py"
|
|
@@ -7,7 +7,7 @@ from __future__ import annotations
|
|
|
7
7
|
from typing import TYPE_CHECKING
|
|
8
8
|
|
|
9
9
|
from diot import Diot
|
|
10
|
-
from pipen.utils import
|
|
10
|
+
from pipen.utils import is_loading_pipeline
|
|
11
11
|
from pipen_args.procgroup import ProcGroup
|
|
12
12
|
|
|
13
13
|
if TYPE_CHECKING:
|
|
@@ -20,9 +20,9 @@ class CellRangerCountPipeline(ProcGroup):
|
|
|
20
20
|
Run cellranger count for multiple samples and summarize the metrics.
|
|
21
21
|
|
|
22
22
|
Args:
|
|
23
|
-
input (
|
|
23
|
+
input (list): The list of lists of fastq files.
|
|
24
24
|
or the list of comma-separated string of fastq files.
|
|
25
|
-
ids (
|
|
25
|
+
ids (list): The list of ids for the samples.
|
|
26
26
|
"""
|
|
27
27
|
DEFAULTS = Diot(input=None, ids=None)
|
|
28
28
|
|
|
@@ -76,9 +76,9 @@ class CellRangerVdjPipeline(ProcGroup):
|
|
|
76
76
|
Run cellranger vdj for multiple samples and summarize the metrics.
|
|
77
77
|
|
|
78
78
|
Args:
|
|
79
|
-
input (
|
|
79
|
+
input (list): The list of lists of fastq files.
|
|
80
80
|
or the list of comma-separated string of fastq files.
|
|
81
|
-
ids (
|
|
81
|
+
ids (list): The list of ids for the samples.
|
|
82
82
|
"""
|
|
83
83
|
DEFAULTS = Diot(input=None, ids=None)
|
|
84
84
|
|
biopipen/ns/cnv.py
CHANGED
|
@@ -12,7 +12,15 @@ class AneuploidyScore(Proc):
|
|
|
12
12
|
|
|
13
13
|
Input:
|
|
14
14
|
segfile: The seg file, generally including chrom, start, end and
|
|
15
|
-
seg.mean (the log2 ratio)
|
|
15
|
+
seg.mean (the log2 ratio).
|
|
16
|
+
It is typically a tab-delimited file or a BED file.
|
|
17
|
+
If so, envs.chrom_col, envs.start_col, envs.end_col and envs.seg_col
|
|
18
|
+
are the 1st, 2nd, 3rd and 5th columns, respectively.
|
|
19
|
+
It can also be a VCF file. If so, envs.chrom_col and envs.start_col
|
|
20
|
+
are not required.
|
|
21
|
+
`end_col` and `envs.seg_col` will be a field in the INFO column.
|
|
22
|
+
[`VariantAnnotation`](https://rdrr.io/bioc/VariantAnnotation/)
|
|
23
|
+
is required to extract the INFO field.
|
|
16
24
|
|
|
17
25
|
Output:
|
|
18
26
|
outdir: The output directory containing the CAAs, AS and a histogram
|
|
@@ -122,7 +130,15 @@ class TMADScore(Proc):
|
|
|
122
130
|
Input:
|
|
123
131
|
segfile: The seg file, two columns are required:
|
|
124
132
|
* chrom: The chromosome name, used for filtering
|
|
125
|
-
* seg.mean: The log2 ratio
|
|
133
|
+
* seg.mean: The log2 ratio.
|
|
134
|
+
It is typically a tab-delimited file or a BED file.
|
|
135
|
+
If so, envs.chrom_col and envs.seg_col
|
|
136
|
+
are the 1st and 5th columns, respectively.
|
|
137
|
+
It can also be a VCF file. If so, envs.chrom_col and envs.start_col
|
|
138
|
+
are not required.
|
|
139
|
+
`end_col` and `envs.seg_col` will be a field in the INFO column.
|
|
140
|
+
[`VariantAnnotation`](https://rdrr.io/bioc/VariantAnnotation/)
|
|
141
|
+
is required to extract the INFO field.
|
|
126
142
|
|
|
127
143
|
Output:
|
|
128
144
|
outfile: The output file containing the TMAD score
|
biopipen/ns/cnvkit_pipeline.py
CHANGED
|
@@ -487,7 +487,8 @@ class CNVkitPipeline(ProcGroup):
|
|
|
487
487
|
target_file = None
|
|
488
488
|
antitarget_file = None
|
|
489
489
|
if self.col.sex in metadf:
|
|
490
|
-
|
|
490
|
+
all_sex = metadf[self.col.sex][control_masks].unique()
|
|
491
|
+
sample_sex = [None] if len(all_sex) > 1 else all_sex[0]
|
|
491
492
|
else:
|
|
492
493
|
sample_sex = [None]
|
|
493
494
|
else:
|
|
@@ -774,13 +775,15 @@ class CNVkitPipeline(ProcGroup):
|
|
|
774
775
|
else:
|
|
775
776
|
tumor_masks = metadf[self.col.group] == self.opts.case
|
|
776
777
|
|
|
778
|
+
if self.col.sex in metadf:
|
|
779
|
+
all_sex = metadf[self.col.sex][tumor_masks].unique()
|
|
780
|
+
sample_sex = [None] if len(all_sex) > 1 else all_sex[0]
|
|
781
|
+
else:
|
|
782
|
+
sample_sex = [None]
|
|
783
|
+
|
|
777
784
|
return tibble(
|
|
778
785
|
segfiles=[ch2.outfile.tolist()],
|
|
779
|
-
sample_sex=
|
|
780
|
-
",".join(metadf[self.col.sex][tumor_masks])
|
|
781
|
-
if self.col.sex in metadf
|
|
782
|
-
else [None]
|
|
783
|
-
),
|
|
786
|
+
sample_sex=sample_sex,
|
|
784
787
|
)
|
|
785
788
|
|
|
786
789
|
@annotate.format_doc(indent=3)
|
|
@@ -823,13 +826,15 @@ class CNVkitPipeline(ProcGroup):
|
|
|
823
826
|
else:
|
|
824
827
|
tumor_masks = metadf[self.col.group] == self.opts.case
|
|
825
828
|
|
|
829
|
+
if self.col.sex in metadf:
|
|
830
|
+
all_sex = metadf[self.col.sex][tumor_masks].unique()
|
|
831
|
+
sample_sex = [None] if len(all_sex) > 1 else all_sex[0]
|
|
832
|
+
else:
|
|
833
|
+
sample_sex = [None]
|
|
834
|
+
|
|
826
835
|
return tibble(
|
|
827
836
|
segfiles=[ch2.outfile.tolist()],
|
|
828
|
-
sample_sex=
|
|
829
|
-
",".join(metadf[self.col.sex][tumor_masks])
|
|
830
|
-
if self.col.sex in metadf
|
|
831
|
-
else [None]
|
|
832
|
-
),
|
|
837
|
+
sample_sex=sample_sex,
|
|
833
838
|
)
|
|
834
839
|
|
|
835
840
|
@annotate.format_doc(indent=3)
|
biopipen/ns/gene.py
CHANGED
|
@@ -9,46 +9,91 @@ class GeneNameConversion(Proc):
|
|
|
9
9
|
|
|
10
10
|
Input:
|
|
11
11
|
infile: The input file with original gene names
|
|
12
|
+
It should be a tab-separated file with header
|
|
12
13
|
|
|
13
14
|
Output:
|
|
14
15
|
outfile: The output file with converted gene names
|
|
15
16
|
|
|
16
17
|
Envs:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
18
|
+
notfound (choice): What to do if a conversion cannot be done.
|
|
19
|
+
- use-query: Ignore the conversion and use the original name
|
|
20
|
+
- skip: Ignore the conversion and skip the entire row in input file
|
|
21
|
+
- ignore: Same as skip
|
|
22
|
+
- error: Report error
|
|
23
|
+
- na: Use NA
|
|
24
|
+
dup (choice): What to do if a conversion results in multiple names.
|
|
25
|
+
- first: Use the first name, sorted by matching score descendingly (default)
|
|
26
|
+
- last: Use the last name, sorted by matching score descendingly
|
|
27
|
+
- combine: Combine all names using `;` as separator
|
|
28
|
+
genecol: The index (1-based) or name of the column where genes are present
|
|
29
|
+
output (choice): How to output.
|
|
30
|
+
- append: Add the converted names as new columns at the end using `envs.outfmt`
|
|
31
|
+
as the column name.
|
|
32
|
+
- replace: Drop the original name column, and insert
|
|
33
|
+
the converted names at the original position.
|
|
34
|
+
- converted: Only keep the converted names.
|
|
35
|
+
- with-query: Output 2 columns with original and converted names.
|
|
33
36
|
infmt: What's the original gene name format
|
|
34
37
|
Available fields
|
|
35
38
|
https://docs.mygene.info/en/latest/doc/query_service.html#available-fields
|
|
36
|
-
outfmt: What's the target gene name format
|
|
39
|
+
outfmt: What's the target gene name format. Currently only a single format
|
|
40
|
+
is supported.
|
|
37
41
|
species: Limit gene query to certain species.
|
|
38
42
|
Supported: human, mouse, rat, fruitfly, nematode, zebrafish,
|
|
39
43
|
thale-cress, frog and pig
|
|
40
44
|
""" # noqa: E501
|
|
41
45
|
input = "infile:file"
|
|
42
46
|
output = "outfile:file:{{in.infile | basename}}"
|
|
43
|
-
lang = config.lang.
|
|
47
|
+
lang = config.lang.rscript
|
|
44
48
|
envs = {
|
|
45
|
-
"inopts": {"sep": "\t", "index_col": False},
|
|
46
|
-
"outopts": {"sep": "\t", "index": False},
|
|
47
49
|
"notfound": "error",
|
|
48
|
-
"genecol":
|
|
49
|
-
"
|
|
50
|
+
"genecol": 1,
|
|
51
|
+
"dup": "first",
|
|
52
|
+
"output": "append",
|
|
50
53
|
"infmt": ["symbol", "alias"],
|
|
51
54
|
"outfmt": "symbol",
|
|
52
55
|
"species": "human",
|
|
53
56
|
}
|
|
54
|
-
script = "file://../scripts/gene/GeneNameConversion.
|
|
57
|
+
script = "file://../scripts/gene/GeneNameConversion.R"
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class GenePromoters(Proc):
|
|
61
|
+
"""Get gene promoter regions by specifying the flanking regions of TSS
|
|
62
|
+
|
|
63
|
+
Input:
|
|
64
|
+
infile: The input file with gene ids/names
|
|
65
|
+
|
|
66
|
+
Output:
|
|
67
|
+
outfile: The output file with promoter regions in BED format
|
|
68
|
+
|
|
69
|
+
Envs:
|
|
70
|
+
up (type=int): The upstream distance from TSS
|
|
71
|
+
down (type=int): The downstream distance from TSS
|
|
72
|
+
If not specified, the default is `envs.up`
|
|
73
|
+
notfound (choice): What to do if a gene is not found.
|
|
74
|
+
- skip: Skip the gene
|
|
75
|
+
- error: Report error
|
|
76
|
+
refgene: The reference gene annotation file in GTF format
|
|
77
|
+
header (flag): Whether the input file has a header
|
|
78
|
+
genecol (type=int): The index (1-based) of the gene column
|
|
79
|
+
match_id (flag): Should we match the genes in `in.infile` by `gene_id`
|
|
80
|
+
instead of `gene_name` in `envs.refgene`
|
|
81
|
+
sort (flag): Sort the output by chromosome and start position
|
|
82
|
+
chrsize: The chromosome size file, from which the chromosome order is
|
|
83
|
+
used to sort the output
|
|
84
|
+
"""
|
|
85
|
+
input = "infile:file"
|
|
86
|
+
output = "outfile:file:{{in.infile | stem}}-promoters.bed"
|
|
87
|
+
lang = config.lang.rscript
|
|
88
|
+
envs = {
|
|
89
|
+
"up": 2000,
|
|
90
|
+
"down": None,
|
|
91
|
+
"notfound": "error",
|
|
92
|
+
"refgene": config.ref.refgene,
|
|
93
|
+
"header": True,
|
|
94
|
+
"genecol": 1,
|
|
95
|
+
"match_id": False,
|
|
96
|
+
"sort": False,
|
|
97
|
+
"chrsize": config.ref.chrsize,
|
|
98
|
+
}
|
|
99
|
+
script = "file://../scripts/gene/GenePromoters.R"
|
biopipen/ns/misc.py
CHANGED
|
@@ -80,7 +80,7 @@ class Str2File(Proc):
|
|
|
80
80
|
name: The name of the output file
|
|
81
81
|
"""
|
|
82
82
|
input = "str, name"
|
|
83
|
-
output = "outfile:file:{{in.name}}"
|
|
83
|
+
output = "outfile:file:{{in.name | default: 'unnamed.txt'}}"
|
|
84
84
|
lang = config.lang.python
|
|
85
85
|
envs = {"name": None}
|
|
86
86
|
script = "file://../scripts/misc/Str2File.py"
|
|
@@ -105,17 +105,4 @@ class Shell(Proc):
|
|
|
105
105
|
output = "outfile:file:{{in.infile | basename}}"
|
|
106
106
|
envs = {"cmd": "", "outdir": False}
|
|
107
107
|
lang = config.lang.bash
|
|
108
|
-
script = ""
|
|
109
|
-
infile={{in.infile | quote}}
|
|
110
|
-
outfile={{out.outfile | quote}}
|
|
111
|
-
is_outdir={{envs.outdir | int}}
|
|
112
|
-
cmd={{envs.cmd | quote}}
|
|
113
|
-
if [[ -z "$cmd" ]]; then
|
|
114
|
-
echo "No command given." 1>&2
|
|
115
|
-
exit 1
|
|
116
|
-
fi
|
|
117
|
-
if [[ $is_outdir -eq 1 ]]; then
|
|
118
|
-
mkdir -p "$outfile"
|
|
119
|
-
fi
|
|
120
|
-
eval "$cmd"
|
|
121
|
-
"""
|
|
108
|
+
script = "file://../scripts/misc/Shell.sh"
|
biopipen/ns/plot.py
CHANGED
|
@@ -150,3 +150,207 @@ class ROC(Proc):
|
|
|
150
150
|
"show_auc": True,
|
|
151
151
|
}
|
|
152
152
|
script = "file://../scripts/plot/ROC.R"
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
class Manhattan(Proc):
|
|
156
|
+
"""Plot Manhattan plot.
|
|
157
|
+
|
|
158
|
+
Using the [`ggmanh`](https://bioconductor.org/packages/devel/bioc/vignettes/ggmanh/inst/doc/ggmanh.html) package.
|
|
159
|
+
Requires `ggmanh` v1.9.6 or later.
|
|
160
|
+
|
|
161
|
+
Input:
|
|
162
|
+
infile: The input file for data
|
|
163
|
+
It should contain at least three columns, the chromosome, the position
|
|
164
|
+
and the p-value of the SNPs.
|
|
165
|
+
Header is required.
|
|
166
|
+
|
|
167
|
+
Output:
|
|
168
|
+
outfile: The output figure file
|
|
169
|
+
|
|
170
|
+
Envs:
|
|
171
|
+
chrom_col: The column for chromosome
|
|
172
|
+
An integer (1-based) or a string indicating the column name.
|
|
173
|
+
pos_col: The column for position
|
|
174
|
+
An integer (1-based) or a string indicating the column name.
|
|
175
|
+
pval_col: The column for p-value
|
|
176
|
+
An integer (1-based) or a string indicating the column name.
|
|
177
|
+
label_col: The column for label.
|
|
178
|
+
Once specified, the significant SNPs will be labeled on the plot.
|
|
179
|
+
devpars (ns): The parameters for `png()`
|
|
180
|
+
- res (type=int): The resolution
|
|
181
|
+
- width (type=int): The width
|
|
182
|
+
- height (type=int): The height
|
|
183
|
+
title: The title of the plot
|
|
184
|
+
ylabel: The y-axis label
|
|
185
|
+
rescale (flag): Whether to rescale the p-values
|
|
186
|
+
rescale_ratio_threshold (type=float): Threshold of that triggers the rescale
|
|
187
|
+
signif (auto): A single value or a list of values to indicate the significance levels
|
|
188
|
+
Multiple values should be also separated by comma (`,`).
|
|
189
|
+
The minimum value will be used as the cutoff to determine if the SNPs are significant.
|
|
190
|
+
hicolors (auto): The colors for significant and non-significant SNPs
|
|
191
|
+
If a single color is given, the non-significant SNPs will be in grey.
|
|
192
|
+
Set it to None to disable the highlighting.
|
|
193
|
+
thin_n (type=int): Number of max points per horizontal partitions of the plot.
|
|
194
|
+
`0` or `None` to disable thinning.
|
|
195
|
+
thin_bins (type=int): Number of bins to partition the data.
|
|
196
|
+
zoom (auto): Chromosomes to zoom in
|
|
197
|
+
Each chromosome should be separated by comma (`,`) or in a list. Single chromosome is also accepted.
|
|
198
|
+
Ranges are also accepted, see `envs.chroms`.
|
|
199
|
+
Each chromosome will be saved in a separate file.
|
|
200
|
+
zoom_devpars (ns): The parameters for the zoomed plot
|
|
201
|
+
- width (type=int): The width
|
|
202
|
+
- height (type=int): The height, inherited from `devpars` by default
|
|
203
|
+
- res (type=int): The resolution, inherited from `devpars` by default
|
|
204
|
+
chroms (auto): The chromosomes and order to plot
|
|
205
|
+
A hyphen (`-`) can be used to indicate a range.
|
|
206
|
+
For example `chr1-22,chrX,chrY,chrM` will plot all autosomes, X, Y and M.
|
|
207
|
+
if `auto`, only the chromosomes in the data will be plotted in the order
|
|
208
|
+
they appear in the data.
|
|
209
|
+
args (ns): Additional arguments for `manhattan_plot()`.
|
|
210
|
+
See <https://rdrr.io/github/leejs-abv/ggmanh/man/manhattan_plot.html>.
|
|
211
|
+
Note that `-` will be replaced by `.` in the argument names.
|
|
212
|
+
- <more>: Additional arguments for `manhattan_plot()`
|
|
213
|
+
""" # noqa: E501
|
|
214
|
+
input = "infile:file"
|
|
215
|
+
output = "outfile:file:{{in.infile | stem0}}.manhattan.png"
|
|
216
|
+
lang = config.lang.rscript
|
|
217
|
+
envs = {
|
|
218
|
+
"chrom_col": 1,
|
|
219
|
+
"pos_col": 2,
|
|
220
|
+
"pval_col": 3,
|
|
221
|
+
"label_col": None,
|
|
222
|
+
"devpars": {"res": 100, "width": 1000, "height": 500},
|
|
223
|
+
"zoom_devpars": {"width": 500, "height": None, "res": None},
|
|
224
|
+
"title": None,
|
|
225
|
+
"ylabel": "-log10(p-value)",
|
|
226
|
+
"rescale": True,
|
|
227
|
+
"rescale_ratio_threshold": 5,
|
|
228
|
+
"signif": [5e-8, 1e-5],
|
|
229
|
+
"hicolors": None,
|
|
230
|
+
"thin_n": None,
|
|
231
|
+
"thin_bins": 200,
|
|
232
|
+
"zoom": None,
|
|
233
|
+
"chroms": "auto",
|
|
234
|
+
"args": {},
|
|
235
|
+
}
|
|
236
|
+
script = "file://../scripts/plot/Manhattan.R"
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
class QQPlot(Proc):
|
|
240
|
+
"""Generate QQ-plot or PP-plot using qqplotr.
|
|
241
|
+
|
|
242
|
+
See <https://cran.r-project.org/web/packages/qqplotr/vignettes/introduction.html>.
|
|
243
|
+
|
|
244
|
+
Input:
|
|
245
|
+
infile: The input file for data
|
|
246
|
+
It should contain at least one column of p-values or the values to be
|
|
247
|
+
plotted. Header is required.
|
|
248
|
+
theorfile: The file for theoretical values (optional)
|
|
249
|
+
This file should contain at least one column of theoretical values.
|
|
250
|
+
The values will be passed to `envs.theor_qfunc` to calculate the theoretical
|
|
251
|
+
quantiles.
|
|
252
|
+
Header is required.
|
|
253
|
+
|
|
254
|
+
Output:
|
|
255
|
+
outfile: The output figure file
|
|
256
|
+
|
|
257
|
+
Envs:
|
|
258
|
+
val_col: The column for values to be plotted
|
|
259
|
+
An integer (1-based) or a string indicating the column name.
|
|
260
|
+
devpars (ns): The parameters for `png()`
|
|
261
|
+
- res (type=int): The resolution
|
|
262
|
+
- width (type=int): The width
|
|
263
|
+
- height (type=int): The height
|
|
264
|
+
xlabel: The x-axis label
|
|
265
|
+
ylabel: The y-axis label
|
|
266
|
+
title: The title of the plot
|
|
267
|
+
trans: The transformation of the values
|
|
268
|
+
You can use `-log10` to transform the values to `-log10(values)`.
|
|
269
|
+
Otherwise you can a direct R function or a custom R function.
|
|
270
|
+
For example `function(x) -log10(x)`.
|
|
271
|
+
kind (choice): The kind of the plot, `qq` or `pp`
|
|
272
|
+
- qq: QQ-plot
|
|
273
|
+
- pp: PP-plot
|
|
274
|
+
theor_col: The column for theoretical values in `in.theorfile` if provided,
|
|
275
|
+
otherwise in `in.infile`.
|
|
276
|
+
An integer (1-based) or a string indicating the column name.
|
|
277
|
+
If `distribution` of `band`, `line`, or `point` is `custom`, this column
|
|
278
|
+
must be provided.
|
|
279
|
+
theor_trans: The transformation of the theoretical values.
|
|
280
|
+
The `theor_funs` have default functions to take the theoretical values.
|
|
281
|
+
This transformation will be applied to the theoretical values before
|
|
282
|
+
passing to the `theor_funs`.
|
|
283
|
+
theor_funs (ns): The R functions to generate density, quantile and deviates
|
|
284
|
+
of the theoretical distribution base on the theoretical values
|
|
285
|
+
if `distribution` of `band`, `line`, or `point` is `custom`.
|
|
286
|
+
- dcustom: The density function, used by band
|
|
287
|
+
- qcustom: The quantile function, used by point
|
|
288
|
+
- rcustom: The deviates function, used by line
|
|
289
|
+
args (ns): The common arguments for `envs.band`, `envs.line` and `envs.point`.
|
|
290
|
+
- distribution: The distribution of the theoretical quantiles
|
|
291
|
+
When `custom` is used, the `envs.theor_col` should be provided and
|
|
292
|
+
`values` will be added to `dparams` automatically.
|
|
293
|
+
- dparams (type=json): The parameters for the distribution
|
|
294
|
+
- <more>: Other shared arguments between `stat_*_band`, `stat_*_line`
|
|
295
|
+
and `stat_*_point`.
|
|
296
|
+
band (ns): The arguments for `stat_qq_band()` or `stat_pp_band()`.
|
|
297
|
+
See <https://rdrr.io/cran/qqplotr/man/stat_qq_band.html> and
|
|
298
|
+
<https://rdrr.io/cran/qqplotr/man/stat_pp_band.html>.
|
|
299
|
+
Set to `None` or `band.disabled` to True to disable the band.
|
|
300
|
+
- disabled (flag): Disable the band
|
|
301
|
+
- distribution: The distribution of the theoretical quantiles
|
|
302
|
+
When `custom` is used, the `envs.theor_col` should be provided and
|
|
303
|
+
`values` will be added to `dparams` automatically.
|
|
304
|
+
- dparams (type=json): The parameters for the distribution
|
|
305
|
+
- <more>: Additional arguments for `stat_qq_band()` or `stat_pp_band()`
|
|
306
|
+
line (ns): The arguments for `stat_qq_line()` or `stat_pp_line()`.
|
|
307
|
+
See <https://rdrr.io/cran/qqplot/man/stat_qq_line.html> and
|
|
308
|
+
<https://rdrr.io/cran/qqplot/man/stat_pp_line.html>.
|
|
309
|
+
Set to `None` or `line.disabled` to True to disable the line.
|
|
310
|
+
- disabled (flag): Disable the line
|
|
311
|
+
- distribution: The distribution of the theoretical quantiles
|
|
312
|
+
When `custom` is used, the `envs.theor_col` should be provided and
|
|
313
|
+
`values` will be added to `dparams` automatically.
|
|
314
|
+
- dparams (type=json): The parameters for the distribution
|
|
315
|
+
- <more>: Additional arguments for `stat_qq_line()` or `stat_pp_line()`
|
|
316
|
+
point (ns): The arguments for `geom_qq_point()` or `geom_pp_point()`.
|
|
317
|
+
See <https://rdrr.io/cran/qqplot/man/stat_qq_point.html> and
|
|
318
|
+
<https://rdrr.io/cran/qqplot/man/stat_pp_point.html>.
|
|
319
|
+
Set to `None` or `point.disabled` to True to disable the point.
|
|
320
|
+
- disabled (flag): Disable the point
|
|
321
|
+
- distribution: The distribution of the theoretical quantiles
|
|
322
|
+
When `custom` is used, the `envs.theor_col` should be provided and
|
|
323
|
+
`values` will be added to `dparams` automatically.
|
|
324
|
+
- dparams (type=json): The parameters for the distribution
|
|
325
|
+
- <more>: Additional arguments for `geom_qq_point()` or `geom_pp_point()`
|
|
326
|
+
ggs (list): Additional ggplot expression to adjust the plot.
|
|
327
|
+
"""
|
|
328
|
+
input = "infile:file, theorfile:file"
|
|
329
|
+
output = "outfile:file:{{in.infile | stem}}.{{envs.kind}}.png"
|
|
330
|
+
lang = config.lang.rscript
|
|
331
|
+
envs = {
|
|
332
|
+
"val_col": 1,
|
|
333
|
+
"theor_col": None,
|
|
334
|
+
"theor_trans": None,
|
|
335
|
+
"theor_funs": {
|
|
336
|
+
"dcustom": """
|
|
337
|
+
function(x, values, ...) {
|
|
338
|
+
density(values, from = min(values), to = max(values), n = length(x))$y
|
|
339
|
+
}
|
|
340
|
+
""",
|
|
341
|
+
"qcustom": "function(p, values, ...) {quantile(values, probs = p)}",
|
|
342
|
+
"rcustom": "function(n, values, ...) { sample(values, n, replace = TRUE) }",
|
|
343
|
+
},
|
|
344
|
+
"args": {"distribution": "norm", "dparams": {}},
|
|
345
|
+
"devpars": {"res": 100, "width": 1000, "height": 1000},
|
|
346
|
+
"xlabel": "Theoretical Quantiles",
|
|
347
|
+
"ylabel": "Observed Quantiles",
|
|
348
|
+
"title": "QQ-plot",
|
|
349
|
+
"trans": None,
|
|
350
|
+
"kind": "qq",
|
|
351
|
+
"band": {"disabled": False, "distribution": None, "dparams": None},
|
|
352
|
+
"line": {"disabled": False, "distribution": None, "dparams": None},
|
|
353
|
+
"point": {"disabled": False, "distribution": None, "dparams": None},
|
|
354
|
+
"ggs": None,
|
|
355
|
+
}
|
|
356
|
+
script = "file://../scripts/plot/QQPlot.R"
|