Skip to content

Commit

Permalink
time
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhuoqing Fang authored and Zhuoqing Fang committed Dec 6, 2024
1 parent c5373e1 commit 9467c38
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions gseapy/gsea.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,15 +308,15 @@ def load_classes(self, classes: Union[str, List[str], Dict[str, Any]]):
self.pheno_neg = neg
self.groups = cls_vector

if self._outdir is not None:
self.to_cls(outdir=self.outdir)

def to_cls(self, outdir: str):
"""Save group information to cls file"""
with open(os.path.join(outdir, "group.cls"), "w") as f:
f.write(f"{len(self.groups)} 2 1\n")
f.write(f"# {self.pheno_pos} {self.pheno_neg}\n")
f.write(" ".join(self.groups) + "\n")
if isinstance(self.groups, dict):
f.write(" ".join(list(self.groups.values())) + "\n")
else:
f.write(" ".join(self.groups) + "\n")

# @profile
def run(self):
Expand Down Expand Up @@ -411,6 +411,7 @@ def run(self):
# write output and plotting
self.to_df(gsum.summaries, gmt, self.ranking)
if self._outdir is not None:
self.to_cls(outdir=self.outdir)
self.ranking.to_csv(
os.path.join(self.outdir, "gsea_data.rnk"), sep="\t", header=False
)
Expand Down

0 comments on commit 9467c38

Please sign in to comment.