Skip to content

Commit

Permalink
Merge pull request #5 from s-a-nersisyan/main
Browse files Browse the repository at this point in the history
Fixed bugs with gene names order and chunk-wise export
  • Loading branch information
narek01 authored May 31, 2024
2 parents 9c1b4c1 + 9773c45 commit 9295d73
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
3 changes: 3 additions & 0 deletions dcona/lib/dump.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import tqdm
import sys
import os
import numpy as np

from ..core import extern as cextern

Expand Down Expand Up @@ -41,6 +42,8 @@ def save_by_chunks(

if (isinstance(df_indexes, tuple)) and (len(df_indexes) == 2):
source_indexes, target_indexes = df_indexes
source_indexes = np.array(source_indexes)[dump_indexes]
target_indexes = np.array(target_indexes)[dump_indexes]
else:
source_indexes = []
target_indexes = []
Expand Down
22 changes: 12 additions & 10 deletions dcona/lib/ztest.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def ztest(

if repeats_number is None:
repeats_number = 0

sorted_indexes, df_indexes, \
ref_corrs, ref_pvalues, exp_corrs, exp_pvalues, \
stat, pvalue, adjusted_pvalue, \
Expand Down Expand Up @@ -78,7 +78,6 @@ def ztest(
pvalue, adjusted_pvalue
]


path_to_file = output_dir.rstrip("/") + f"/{correlation}_{alternative}_ztest.csv"
dump.save_by_chunks(
sorted_indexes,
Expand All @@ -89,21 +88,24 @@ def ztest(
print(f"File saved at: {path_to_file}")
return None

source_indexes = []
target_indexes = []

if (isinstance(df_indexes, tuple)) and (len(df_indexes) == 2):
# This "if" is true when user passed interaction_df
source_indexes, target_indexes = df_indexes
source_indexes = np.array(source_indexes)[sorted_indexes]
target_indexes = np.array(target_indexes)[sorted_indexes]
else:
# This "else" is true when user passed no interaction_df
source_indexes = []
target_indexes = []
for ind in sorted_indexes:
s, t = extern.paired_index(ind, len(df_indexes))
source_indexes.append(df_indexes[s])
target_indexes.append(df_indexes[t])

if repeats_number > 0:
output_df = pd.DataFrame(data={
"Source": source_indexes.to_numpy()[sorted_indexes],
"Target": target_indexes.to_numpy()[sorted_indexes],
"Source": source_indexes,
"Target": target_indexes,
"RefCorr": ref_corrs[sorted_indexes],
"RefPvalue": ref_pvalues[sorted_indexes],
"ExpCorr": exp_corrs[sorted_indexes],
Expand All @@ -115,8 +117,8 @@ def ztest(
})
else:
output_df = pd.DataFrame(data={
"Source": source_indexes.to_numpy()[sorted_indexes],
"Target": target_indexes.to_numpy()[sorted_indexes],
"Source": source_indexes,
"Target": target_indexes,
"RefCorr": ref_corrs[sorted_indexes],
"RefPvalue": ref_pvalues[sorted_indexes],
"ExpCorr": exp_corrs[sorted_indexes],
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

requirements = ['pybind11', 'pandas', 'numpy', 'scipy', 'tqdm']

__version__ = "0.2.2"
__version__ = "0.2.3"


ext_modules = [
Expand Down

0 comments on commit 9295d73

Please sign in to comment.