Skip to content

Commit

Permalink
added --name option for plot name
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-fuchs committed Nov 17, 2023
1 parent 4df87fc commit af905a5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ positional arguments:
options:
-h, --help show this help message and exit
--name virHEAT_plot.pdf
plot name and file type (pdf, png, svg, jpg). Default: virHEAT_plot.pdf
-l None, --genome-length None
length of the genome (needed if gff3 is not provided)
-g None, --gff3-path None
Expand Down
15 changes: 12 additions & 3 deletions virheat/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ def get_args(sysargs):
nargs=2,
help="folder containing input files and output folder"
)
parser.add_argument(
"--name",
type=str,
metavar="virHEAT_plot.pdf",
default="virHEAT_plot.pdf",
help="plot name and file type (pdf, png, svg, jpg). Default: virHEAT_plot.pdf"
)
parser.add_argument(
"-l",
"--genome-length",
Expand Down Expand Up @@ -126,22 +133,24 @@ def main(sysargs=sys.argv[1:]):
vcf_files = data_prep.get_files(args.input[0], "vcf")
if args.sort:
vcf_files = sorted(vcf_files, key=lambda x: data_prep.get_digit_and_alpha(os.path.basename(x)))

# extract vcf info
reference_name, frequency_lists, unique_mutations, file_names = data_prep.extract_vcf_data(vcf_files, threshold=args.threshold)
if args.zoom:
unique_mutations = data_prep.zoom_to_genomic_regions(unique_mutations, args.zoom)
frequency_array = data_prep.create_freq_array(unique_mutations, frequency_lists)

# user specified delete options (removes mutations based on various rationales)
if args.delete:
frequency_array = data_prep.delete_common_mutations(frequency_array, unique_mutations)
if args.delete_n is not None:
frequency_array = data_prep.delete_n_mutations(frequency_array, unique_mutations, args.delete_n)

# annotate low coverage if per base coveage from qualimap was provided
data_prep.annotate_non_covered_regions(args.input[0], args.min_cov, frequency_array, file_names, unique_mutations)

# define relative locations of all items in the plot
n_samples = len(frequency_array)
n_mutations = len(frequency_array[0])
n_samples, n_mutations = len(frequency_array), len(frequency_array[0])
if n_mutations == 0:
sys.exit("\033[31m\033[1mERROR:\033[0m Frequency array seems to be empty. There is nothing to plot.")
if n_samples < 4:
Expand Down Expand Up @@ -208,5 +217,5 @@ def main(sysargs=sys.argv[1:]):
os.makedirs(args.input[1])

# save fig
fig.savefig(os.path.join(args.input[1], "virHEAT_plot.pdf"), bbox_inches="tight")
fig.savefig(os.path.join(args.input[1], args.name), bbox_inches="tight")

0 comments on commit af905a5

Please sign in to comment.