Skip to content

Commit

Permalink
Added the option to use negative wps to favor low activity points dur…
Browse files Browse the repository at this point in the history
…ing weighting
  • Loading branch information
rlaplaza committed Sep 16, 2024
1 parent f7b2c60 commit 580d6b5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
15 changes: 13 additions & 2 deletions navicat_spock/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,17 @@ def reweighter(target, wp=2):
weights = np.round(
np.array([py**wp for py in scaled]), decimals=6
) # **2 at least, could be increased
elif wp < 0:
wp = np.abs(wp)
std = target.std()
norm = sum(target) # Not needed since robust regression will normalize
rescaled = [(py - min(target)) + std for py in target]
# print(rescaled)
scaled = [(py / max(abs(target))) for py in rescaled]
# print(scaled)
weights = np.round(
np.array([1 / (py**wp) for py in scaled]), decimals=6
) # **2 at least, could be increased
weights = normalize(weights).reshape(-1)
else:
std = target.std()
Expand Down Expand Up @@ -341,7 +352,7 @@ def processargs(arguments):
epilog="Remember to cite the spock paper (when its out!) \n \n - and enjoy!",
)
vbuilder.add_argument(
"-version", "--version", action="version", version="%(prog)s 0.0.2"
"-version", "--version", action="version", version="%(prog)s 0.0.3"
)
vbuilder.add_argument(
"-i",
Expand All @@ -362,7 +373,7 @@ def processargs(arguments):
dest="wp",
type=int,
default=1,
help="In the regression, integer power with which higher activity points are weighted. Higher means low activity points are given less priority in the fit (default: 1)",
help="In the regression, integer power with which higher activity points are weighted. Higher means low activity points are given less priority in the fit. Negative values will do the opposite and give more weight to low activity points. (default: 1)",
)
vbuilder.add_argument(
"-v",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "navicat-spock"
version = "0.0.2"
version = "0.0.3"
authors = [
{ name="R. Laplaza", email="[email protected]" },
]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
setup(
name="spock",
packages=["navicat_spock"],
version="0.0.2",
version="0.0.3",
description="Volcano Plot fitting tool",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit 580d6b5

Please sign in to comment.