From 92d8f69dfb95ff8e5e748f60b26a57252b3a9221 Mon Sep 17 00:00:00 2001 From: Tom Chartrand Date: Wed, 30 Aug 2023 14:40:38 -0700 Subject: [PATCH] generalize spearman correlation fcm --- patchseq_utils/analysis.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/patchseq_utils/analysis.py b/patchseq_utils/analysis.py index 8bfd104..5967890 100644 --- a/patchseq_utils/analysis.py +++ b/patchseq_utils/analysis.py @@ -617,10 +617,12 @@ def plot_spearman(data, x, y, smooth=True, hue=None, palette=None, verticalalignment='top', horizontalalignment='center') sns.despine() -def run_correlations(data, features, xvar, fdr_method='fdr_bh'): +def run_correlations(data, features, xvar, fdr_method='fdr_bh', filter_dropouts=True): results = [] for gene in features: - if gene not in data or data[gene].pipe(lambda x: sum(x>1)) < 5: + if gene not in data: + continue + if filter_dropouts and data[gene].pipe(lambda x: sum(x>1)) < 5: continue df = data.dropna(subset=[gene, xvar]) r, p = spearmanr(df[gene], df[xvar])