Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhuoqing Fang authored and Zhuoqing Fang committed Nov 13, 2024
1 parent fd916cc commit c1eb602
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gseapy/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ def enrichment_score(
# Test whether each element of a 1-D array is also present in a second array
# It's more intuitive here than original enrichment_score source code.
# use .astype to covert bool to integer
tag_indicator = np.in1d(gene_list, gene_set, assume_unique=True).astype(
tag_indicator = np.isin(gene_list, gene_set, assume_unique=True).astype(
int
) # notice that the sign is 0 (no tag) or 1 (tag)

Expand Down
25 changes: 24 additions & 1 deletion gseapy/msigdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,20 @@ def __init__(self, dbver: str = "2023.1.Hs"):
dbver: MSIGDB version number. default: 2023.1.Hs
"""
self.url = "https://data.broadinstitute.org/gsea-msigdb/msigdb/release/"
self._pattern = re.compile("(\w.+)\.(v\d.+)\.(entrez|symbols)\.gmt")
self._pattern = re.compile(r"(\w.+)\.(v\d.+)\.(entrez|symbols)\.gmt")
self._db_version = self._get_db_version()
if self._db_version is None:
raise Exception("Failed to fetch available MSIGDB versions")
self.categoires = self.list_category(dbver)

def _get_db_version(self):
"""
Get all available MSIGDB versions
Return:
A pd.DataFrame of all available MSIGDB versions.
If failed to fetch, return None.
"""
resp = requests.get(self.url)
if resp.ok:
d = pd.read_html(resp.text)[0]
Expand Down Expand Up @@ -48,6 +57,13 @@ def get_gmt(

def list_dbver(self):
# self._db_version.columns = ["dbver", "date"]
"""
Return a pd.DataFrame of all available MSIGDB versions
Return:
A pd.DataFrame of all available MSIGDB versions.
If failed to fetch, return None.
"""
return self._db_version

def list_category(self, dbver: str = "2023.1.Hs"):
Expand All @@ -66,6 +82,13 @@ def list_category(self, dbver: str = "2023.1.Hs"):
return None

def list_gmt(self, db: str):
"""
list all gmt files in MSIGDB database.
:param db: MSIGDB version number. default: 2023.1.Hs
:return: a pandas DataFrame object
"""

url = self.url + db
resp = requests.get(url)
if resp.ok:
Expand Down

0 comments on commit c1eb602

Please sign in to comment.