Skip to content

Commit

Permalink
update chi test
Browse files Browse the repository at this point in the history
  • Loading branch information
chaochungkuo committed Mar 2, 2024
1 parent 2560ac7 commit 2218bc3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ numpy
pysam==0.22.0
tqdm
pyBigWig==0.3.22
pandas
pandas
scipy
4 changes: 2 additions & 2 deletions genomkit/coverages/gcoverages.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def calculate_coverage_from_bam(self, filename: str):

def calculate_coverage_GRegions(self, regions, scores,
strandness: bool = False):
"""Calculate the coverage from two GRegions. `regions` defines the loci for the coverage
`scores` contains the scores loaded into the coverage.
"""Calculate the coverage from two GRegions. `regions` defines the loci
for the coverage `scores` contains the scores loaded into the coverage.
:param regions: Define the loci and the length of the coverage
:type regions: GRegions
Expand Down
6 changes: 6 additions & 0 deletions genomkit/regions/gregions_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,9 @@ def count_overlaps(self, query_set, percentage: bool = False):
if percentage:
df = df.div(df.sum(axis=1), axis=0) * 100
return df

def test_association(self, another_set):
from scipy.stats import chi2_contingency
contingency_table = self.count_overlaps(query_set=another_set)
chi2_stat, p_val, _, _ = chi2_contingency(contingency_table)
return chi2_stat, p_val
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ numpy
pysam==0.22.0
tqdm
pyBigWig==0.3.22
pandas
pandas
scipy

0 comments on commit 2218bc3

Please sign in to comment.