-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from maxplanck-ie/develop
v1.3.2
- Loading branch information
Showing
12 changed files
with
268 additions
and
22 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: build | ||
|
||
on: | ||
push: | ||
|
||
defaults: | ||
run: | ||
shell: bash -l {0} | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: mamba-org/setup-micromamba@main | ||
with: | ||
environment-file: requirements.yaml | ||
cache-downloads: true | ||
environment-name: ultraheatmap | ||
- name: build | ||
run: | | ||
micromamba activate ultraheatmap | ||
pip install . | ||
- name: addFeatureToMatrix | ||
run: | | ||
micromamba activate ultraheatmap | ||
bash ultraheatmap/test/test_data/addFeatureToMatrix/addFeatureToMatrix.sh | ||
- name: computeOrderedMatrix | ||
run: | | ||
micromamba activate ultraheatmap | ||
bash ultraheatmap/test/test_data/computeOrderedMatrix/computeOrderedMatrix.sh | ||
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,176 @@ | ||
# generating hybrid matrices and plot them by plotHeatmap | ||
|
||
#!/usr/bin/env python | ||
|
||
import os | ||
import subprocess as sp | ||
import glob | ||
import sys | ||
import argparse | ||
import yaml | ||
|
||
def parse_args(): | ||
""" | ||
parsing arguments | ||
""" | ||
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) | ||
|
||
required = parser.add_argument_group('required arguments') | ||
optional = parser.add_argument_group('optional arguments') | ||
|
||
# required argumnets: | ||
required.add_argument("--config", | ||
"-c", | ||
dest="config", | ||
help="config to use to plot heatmap (yaml file)", | ||
required=True) | ||
|
||
# optional arguments: | ||
optional.add_argument("--heatmapOnly", | ||
"-ho", | ||
default=False, | ||
action='store_true', | ||
dest="heatmapOnly", | ||
help="only plot heatmap for given matrices in yaml file") | ||
|
||
|
||
|
||
return parser | ||
|
||
|
||
def main(): | ||
""" | ||
compute_matrix > ultraheatmap (optional) > heatmap (or profile only if no ultraheatmap) | ||
""" | ||
parser = parse_args() | ||
args = parser.parse_args() | ||
with open(os.path.join(args.config), 'r') as stream: | ||
config = yaml.safe_load(stream) | ||
|
||
|
||
# transcriptomics data | ||
try: | ||
path_2_rna = config["path_2_rna"] | ||
except: | ||
path_2_rna = "" | ||
|
||
# regions to plot on | ||
regions_to_plot = config["regions_to_plot"] | ||
|
||
# output params | ||
output_path = config["output_path"] | ||
|
||
matrix_name = os.path.join(output_path, config["matrix_name"]) | ||
scale_region = config["scale_region"] | ||
|
||
heatmap_name = os.path.join(output_path, config["heatmap_name"]) | ||
|
||
bws = " " | ||
names = " " | ||
|
||
for k, v in config["bws"].items(): | ||
bws += v+" " | ||
names += k+" " | ||
|
||
deg_list =[] | ||
deg_names = " " | ||
if config["ultraheatmap_matrix_name"] != "": | ||
for i, deg in enumerate( config["deg_list"]): | ||
deg_list.append(os.path.join(config["path_2_rna"], deg)) | ||
# deg_list = [os.path.join(path_2_rna, "nej_vs_wt_shrunk.tsv")] | ||
deg_names += config["deg_names"][i]+" " | ||
ultraheatmap_matrix_name = os.path.join(output_path, config["ultraheatmap_matrix_name"]) | ||
|
||
|
||
if not args.heatmapOnly: | ||
if scale_region: | ||
cmd = "computeMatrix scale-regions " | ||
cmd += " -S "+bws | ||
cmd += " -R "+regions_to_plot | ||
cmd += " -p 20 " | ||
cmd += "-bs "+str(config["binsize"]) | ||
cmd += " --skipZeros --regionBodyLength "+str(config["regionBodyLength"]) | ||
cmd += " -a "+str(config["after_region"]) | ||
cmd += " -b "+str(config["before_region"]) | ||
cmd += " --missingDataAsZero --skipZeros --samplesLabel "+names | ||
cmd += " -o "+ matrix_name | ||
if config['averageTypeBins']: | ||
cmd += ' --averageTypeBins '+config['averageTypeBins'] | ||
print(cmd) | ||
sp.check_output(cmd, shell = True) | ||
else: | ||
cmd = "computeMatrix reference-point --referencePoint "+config["refpoint"] | ||
cmd += " -S "+bws | ||
cmd += " -R "+regions_to_plot | ||
cmd += " -p 20 --skipZeros " | ||
cmd += " -a "+str(config["after_region"]) | ||
cmd += " -b "+str(config["before_region"]) | ||
cmd += " --missingDataAsZero --skipZeros --samplesLabel "+names | ||
cmd += " -o "+ matrix_name | ||
if config['averageTypeBins']: | ||
cmd += ' --averageTypeBins '+config['averageTypeBins'] | ||
sp.check_output(cmd, shell = True) | ||
if config["ultraheatmap_matrix_name"] != "": | ||
w_mapping = config["w_mapping"] | ||
if w_mapping: | ||
cmd = "addFeatureToMatrix " | ||
cmd += "-m "+ matrix_name | ||
cmd += " -o "+ultraheatmap_matrix_name | ||
cmd += " -t "+" ".join(deg_list) | ||
cmd += " --featureNames "+config['featureNames'] | ||
cmd += " --referencePoint TSS " | ||
cmd += " --genomeGtf "+config["gtf"] | ||
sp.check_output(cmd, shell = True) | ||
else: | ||
cmd = "addFeatureToMatrix " | ||
cmd += "-m "+ matrix_name | ||
cmd += " -o "+ultraheatmap_matrix_name | ||
cmd += " -t "+" ".join(deg_list) | ||
if config['featureNames']: | ||
cmd += " --featureNames "+config['featureNames'] | ||
if config['featureIdColumn']: | ||
cmd += " --featureIdColumn "+config['featureIdColumn'] | ||
print(cmd) | ||
sp.check_output(cmd, shell = True) | ||
|
||
|
||
# plot heatmap | ||
all_samples_names = names | ||
matrix_to_plot = matrix_name | ||
if config["ultraheatmap_matrix_name"] != "": | ||
all_samples_names+= deg_names | ||
matrix_to_plot = ultraheatmap_matrix_name | ||
cmd = "plotHeatmap -m " | ||
cmd += matrix_to_plot | ||
if config["zmin"]: | ||
cmd += " --zMin "+config["zmin"] | ||
if config["zmax"]: | ||
cmd+= " --zMax "+config["zmax"] | ||
if config["colors"]: | ||
cmd += " --colorMap "+config["colors"] | ||
cmd += " -o "+heatmap_name | ||
cmd += " --samplesLabel "+all_samples_names | ||
cmd += " --whatToShow 'heatmap and colorbar' " | ||
if sort_by_sample != "": | ||
cmd += " --sortUsingSamples "+config["sort_by_sample"] | ||
if config["sortUsing"]: | ||
cmd += " --sortUsing "+config["sortUsing"] | ||
if config["sorting_direction"] | ||
"--sortRegions "+config["sorting_direction"] | ||
if config["sorted_regions"] != "": | ||
sorted_regions = os.path.join(output_path, config["sorted_regions"]) | ||
cmd += " --outFileSortedRegions "+sorted_regions | ||
if config["sorted_matrix"] != "": | ||
sorted_matrix = os.path.join(output_path, config["sorted_matrix"]) | ||
cmd += " --outFileNameMatrix "+sorted_matrix | ||
if config["kmeans"]: | ||
cmd += " --kmeans "+config["kmeans"] | ||
if config["clusterUsingSamples"]: | ||
cmd += " --clusterUsingSamples "+config["clusterUsingSamples"] | ||
else: | ||
if config["reg_labels"]: | ||
cmd += " --regionsLabel "+config["reg_labels"] | ||
print(cmd) | ||
sp.check_output(cmd, shell = True) | ||
if __name__ == "__main__": | ||
main() |
36 changes: 36 additions & 0 deletions
36
script/multi_track_matrix_on_groseq_scaleregion-2000_with_deg_wo_mapping.yaml
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,36 @@ | ||
bws: | ||
bw1: "/path/to/bw1.bw" | ||
bw2: "/path/to/bw2.bw" | ||
|
||
path_2_rna: "/path/to/rna" | ||
regions_to_plot: "/path/region.bed" | ||
# output params | ||
output_path: "/path/to/output" | ||
matrix_name: "output.gz" | ||
scale_region: True | ||
before_region: 2000 | ||
after_region: 0 | ||
regionBodyLength: 3500 | ||
binsize: 10 | ||
refpoint: "" | ||
deg_list: ["rn1.tsv", "rna2.tsv"] | ||
deg_names: ["rn1", "rna2"] | ||
ultraheatmap_matrix_name: "appended_output.gz" | ||
w_mapping: False | ||
gtf:"" | ||
featureIdColumn: 'GeneID' | ||
featureNames: 'log2FoldChange' | ||
zmin: "" #lowest intensity to plot | ||
zmax: "" #highest intensity to plot | ||
colors: "" #matplot lib colors | ||
averageTypeBins: "" | ||
sortUsing: "" | ||
sort_by_sample: "" | ||
sorting_direction: " descend " | ||
reg_labels: " " | ||
heatmap_name: "plotname.png" | ||
sorted_regions: "" | ||
sorted_matrix: "" | ||
remove_na: False | ||
kmeans: "" | ||
clusterUsingSamples: "" |
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 +1 @@ | ||
__version__ = '1.3.1' | ||
__version__ = '1.3.2' |
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
4 changes: 2 additions & 2 deletions
4
ultraheatmap/test/test_data/addFeatureToMatrix/addFeatureToMatrix.sh
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,3 +1,3 @@ | ||
#!/usr/bin/env bash | ||
computeMatrix reference-point -S ../scores.bw -R ../regions.bed -o matrix.gz | ||
addFeatureToMatrix -m matrix.gz -o appended_matrix.gz -t features.bed -f score1 score2 --featureIdColumn name | ||
computeMatrix reference-point -S ultraheatmap/test/test_data/scores.bw -R ultraheatmap/test/test_data/regions.bed -o matrix.gz | ||
addFeatureToMatrix -m matrix.gz -o appended_matrix.gz -t ultraheatmap/test/test_data/addFeatureToMatrix/features.bed -f score1 score2 --featureIdColumn name |
2 changes: 1 addition & 1 deletion
2
ultraheatmap/test/test_data/computeOrderedMatrix/computeOrderedMatrix.sh
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,2 +1,2 @@ | ||
#!/usr/bin/env bash | ||
computeOrderedMatrix -S ../scores.bw ../scores.bw -R ../regions.bed -o matrix_ordered.gz -g 1 --kmean 2 | ||
computeOrderedMatrix -S ultraheatmap/test/test_data/scores.bw ultraheatmap/test/test_data/scores.bw -R ultraheatmap/test/test_data/regions.bed -o matrix_ordered.gz -g 1 --kmean 2 |