Skip to content

Commit

Permalink
Add coverage factor
Browse files Browse the repository at this point in the history
  • Loading branch information
aghozlane committed Mar 13, 2024
1 parent 0b4f252 commit 1a3a77b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion meteor/merging.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ def execute(self) -> None:
]
if self.remove_sample_with_no_msp:
# Filter the DataFrame to keep only columns with a non-zero sum
filtered_df = filtered_df.loc[:, (merged_df.sum() != 0)]
filtered_df = filtered_df.loc[:, (filtered_df.sum(axis=0) != 0)]
if my_pattern == "msp":
annotation = pd.read_csv(
self.meteor.ref_dir
Expand Down
8 changes: 8 additions & 0 deletions meteor/meteor.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,13 @@ def get_arguments() -> Namespace: # pragma: no cover
default="coverage",
help="Normalization applied to gene abundance (default coverage).",
)
profiling_parser.add_argument(
"-c",
dest="coverage_factor",
type=float,
default=100.0,
help="Multiplication factor for coverage normalization (Default 100.0).",
)
profiling_parser.add_argument(
"--core_size",
dest="core_size",
Expand Down Expand Up @@ -732,6 +739,7 @@ def main() -> None: # pragma: no cover
args.core_size,
args.msp_filter,
args.completeness,
args.coverage_factor,
)
profiler.execute()
# Run merging
Expand Down
7 changes: 4 additions & 3 deletions meteor/profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Profiler(Session):
core_size: int
msp_filter: float
completeness: float
coverage_factor: float = 100.0

def __post_init__(self):
# Get the json file
Expand Down Expand Up @@ -199,11 +200,11 @@ def normalize_coverage(self, trim_length: int) -> None:
]

choicelist = [
(100.0 * self.gene_count["value"])
(self.coverage_factor * self.gene_count["value"])
/ (self.gene_count["gene_length"] - trim_length + 1),
(100.0 * self.gene_count["value"] * 4 * trim_length)
(self.coverage_factor * self.gene_count["value"] * 4 * trim_length)
/ (self.gene_count["gene_length"] * (self.gene_count["gene_length"] + 2)),
(100.0 * self.gene_count["value"] * 4 * trim_length)
(self.coverage_factor * self.gene_count["value"] * 4 * trim_length)
/ (self.gene_count["gene_length"] + 1) ** 2,
]
self.gene_count["value"] = np.select(condlist, choicelist)
Expand Down

0 comments on commit 1a3a77b

Please sign in to comment.