Skip to content

Commit

Permalink
changed common mut dele and switched -a arg to store true
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-fuchs committed Oct 24, 2023
1 parent 51a312c commit 7937520
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
11 changes: 6 additions & 5 deletions virheat/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ def get_args(sysargs):
"-a",
"--gff3-annotations",
type=str,
action="store",
metavar="gene",
default="gene",
help="annotations to display from gff3 file (standard: gene). Multiple possible (comma seperated)"
nargs="*",
default=["gene"],
help="annotations to display from gff3 file (standard: gene). Multiple possible."
)
parser.add_argument(
"-t",
Expand All @@ -68,7 +70,7 @@ def get_args(sysargs):
"--delete",
action=argparse.BooleanOptionalAction,
default=True,
help="delete mutations with frequencies present in all samples"
help="delete mutations that are present in all samples and their maximum frequency divergence is smaller than 0.2"
)
parser.add_argument(
"--sort",
Expand Down Expand Up @@ -136,8 +138,7 @@ def main(sysargs=sys.argv[1:]):
if gff3_ref_name not in reference_name and reference_name not in gff3_ref_name:
print("\033[31m\033[1mWARNING:\033[0m gff3 reference does not match the vcf reference!")
genome_end = data_prep.get_genome_end(gff3_info)
annotation_list = args.gff3_annotations.split(",")
genes_with_mutations, n_tracks = data_prep.create_track_dict(unique_mutations, gff3_info, annotation_list)
genes_with_mutations, n_tracks = data_prep.create_track_dict(unique_mutations, gff3_info, args.gff3_annotations)
# define space for the genome vis tracks
min_y_location = genome_y_location + genome_y_location/2 * (n_tracks+1)
elif args.genome_length is not None:
Expand Down
7 changes: 6 additions & 1 deletion virheat/scripts/data_prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,12 @@ def delete_common_mutations(frequency_array, unique_mutations):
check_all = []
for frequency_list in frequency_array:
check_all.append(frequency_list[idx])
if all(x>0 for x in check_all) or all(x==0 for x in check_all):
# check if all mutation in a column are zero (happens with some weird callers)
if all(x == 0 for x in check_all):
mut_to_del.append(idx)
# check if frequencies are present in all columns and the maximal diff is greater than 0.2
# example [0.8, 0.7, 0.6] is not deleted whereas [0.8, 0.7, 0.7] is deleted
elif all(x > 0 for x in check_all) and max(check_all)-min(check_all) >= 0.2:
mut_to_del.append(idx)

for idx in sorted(mut_to_del, reverse=True):
Expand Down

0 comments on commit 7937520

Please sign in to comment.