Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jon dev5 #31

Merged
merged 3 commits into from
Apr 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions stream2/tools/_markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,25 +203,25 @@ def xicorr(x, y, n):


@nb.njit(parallel=True)
def xicorr_ps(X, y):
def xicorr_ps(x, Y):
"""Fast xi correlation coefficient
X: 2d np.array
y: 0d np.array
x: 0d np.array
Y: 2d np.array
"""
n = len(X)
corrs = np.zeros(X.shape[1])
pvals = np.zeros(X.shape[1])
for i in nb.prange(X.shape[1]):
corrs[i], pvals[i] = xicorr(X[:, i], y, n)
n = len(Y)
corrs = np.zeros(Y.shape[1])
pvals = np.zeros(Y.shape[1])
for i in nb.prange(Y.shape[1]):
corrs[i], pvals[i] = xicorr(x,Y[:, i], n)
return corrs, pvals


def spearman_ps(y, X):
def spearman_ps(x, Y):
"""Fast spearman correlation coefficient
X: 2d np.array
y: 0d np.array
"""
return pearson_corr(rankdata(y[None]), rankdata(X.T))
return pearson_corr(rankdata(x[None]), rankdata(Y.T))


def pearson_corr(arr1, arr2):
Expand Down Expand Up @@ -366,7 +366,7 @@ def detect_transition_markers(
+ " cells ..."
)
input_markers_expressed = np.array(input_markers)[
np.where((df_sc[input_markers] != 0).sum(axis=0) > min_num_cells)[0]
np.where((df_sc[input_markers]>0).sum(axis=0) > min_num_cells)[0]
].tolist()
df_marker_detection = df_sc[input_markers_expressed].copy()

Expand Down Expand Up @@ -457,8 +457,8 @@ def detect_transition_markers(
# /!\ dont use df_cells_sort
# and pseudotime_cells_sort, breaks xicorr
res = xicorr_ps(
np.array(df_cells.iloc[:, ix_cutoff]),
np.array(pseudotime_cells),
np.array(df_cells.iloc[:, ix_cutoff])
)
df_stat_pval_qval["stat"] = res[0]
df_stat_pval_qval["pval"] = res[1]
Expand Down
Loading