Skip to content

Commit

Permalink
Merge pull request #36 from Genentech/allow-custom-blacklist
Browse files Browse the repository at this point in the history
  • Loading branch information
avantikalal authored Aug 5, 2024
2 parents 86f8dcb + 55ce1af commit 194a663
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: Publish to PyPI

on:
push:
tags:
tags:
- "*"

jobs:
Expand Down
14 changes: 9 additions & 5 deletions src/grelu/data/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def filter_overlapping(

def filter_blacklist(
data: Union[pd.DataFrame, AnnData],
genome: str,
genome: Optional[str] = None,
blacklist: Optional[str] = None,
inplace: bool = False,
window: int = 0,
Expand All @@ -344,7 +344,7 @@ def filter_blacklist(
data: Either a pandas dataframe of genomic intervals or an Anndata
object with intervals in .var
genome: name of the genome corresponding to intervals
blacklist (str): path to blacklist file. If not given, will be
blacklist: path to blacklist file. If not given, it will be
extracted from the package resources.
inplace: If True, the input is modified in place. If False, a new
dataframe or anndata object is returned.
Expand All @@ -356,12 +356,16 @@ def filter_blacklist(
from grelu.io.bed import read_bed
from grelu.resources import get_blacklist_file

# Read blacklist
# Get path to blacklist file
if genome is not None:
blacklist = get_blacklist_file(genome)
else:
assert (
blacklist is not None
), "Either genome name or blacklist file must be provided"

if isinstance(blacklist, str):
blacklist = read_bed(blacklist, str_index=False)
# Read blacklist file
blacklist = read_bed(blacklist, str_index=False)

# Filter
return filter_overlapping(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import torch

import wandb

from grelu.model.models import (
BorzoiModel,
BorzoiPretrainedModel,
Expand Down

0 comments on commit 194a663

Please sign in to comment.