print(stats.pointbiserialr(apb,a)) print('kendalltau:') print(stats.kendalltau(l,m)) print(stats.kendalltau(a,b)) print('linregress:') print(stats.linregress(l,m)) print(stats.linregress(a,b)) print('\nINFERENTIAL') print('ttest_1samp:') print(stats.ttest_1samp(l,12)) print(stats.ttest_1samp(a,12)) print('ttest_ind:') print(stats.ttest_ind(l,m)) print(stats.ttest_ind(a,b)) print('ttest_rel:') print(stats.ttest_rel(l,m)) print(stats.ttest_rel(a,b)) print('chisquare:') print(stats.chisquare(l)) print(stats.chisquare(a)) print('ks_2samp:') print(stats.ks_2samp(l,m)) print(stats.ks_2samp(a,b)) print('mannwhitneyu:') print(stats.mannwhitneyu(l,m)) print(stats.mannwhitneyu(a,b)) print('ranksums:') print(stats.ranksums(l,m)) print(stats.ranksums(a,b)) print('wilcoxont:') print(stats.wilcoxont(l,m))
print 'kendalltau:' print stats.kendalltau(l,m) print stats.kendalltau(a,b) print 'linregress:' print stats.linregress(l,m) print stats.linregress(a,b) print '\nINFERENTIAL' print 'ttest_1samp:' print stats.ttest_1samp(l,12) print stats.ttest_1samp(a,12) print 'ttest_ind:' print stats.ttest_ind(l,m) print stats.ttest_ind(a,b) print 'ttest_rel:' print stats.ttest_rel(l,m) print stats.ttest_rel(a,b) print 'chisquare:' print stats.chisquare(l) print stats.chisquare(a) print 'ks_2samp:' print stats.ks_2samp(l,m) print stats.ks_2samp(a,b) print 'mannwhitneyu:' print stats.mannwhitneyu(l,m) print stats.mannwhitneyu(a,b) print 'ranksums:' print stats.ranksums(l,m) print stats.ranksums(a,b) print 'wilcoxont:'
print('\n\nIndependent Samples t-test') a = list(map(float,[11.,16.,20.,17.,10.,12.])) b = list(map(float,[8.,11.,15.,11.,11.,12.,11.,7.])) print('\n\nSHOULD BE ??? <p< (df=) ... ') stats.ttest_ind(a,b,1) print('\n\nRelated Samples t-test') before = list(map(float,[11,16,20,17,10])) after = list(map(float,[8,11,15,11,11])) print('\n\nSHOULD BE t=+2.88, 0.01<p<0.05 (df=4) ... Basic Stats 1st ed, p.359') stats.ttest_rel(before,after,1,'Before','After') print("\n\nPearson's r") y = list(map(float,[8,7,7,6,5,4,4,4,2,0])) x = list(map(float,[0,0,1,1,1,2,2,3,3,4])) print('SHOULD BE -0.94535 (N=10) ... Basic Stats 1st ed, p.190',x,y) print(stats.pearsonr(x,y)) print("\n\nSpearman's r") x = list(map(float,[4,1,9,8,3,5,6,2,7])) y = list(map(float,[3,2,8,6,5,4,7,1,9])) print('\nSHOULD BE +0.85 on the dot (N=9) ... Basic Stats 1st ed, p.193',x,y)
print 'kendalltau:' print stats.kendalltau(l, m) print stats.kendalltau(a, b) print 'linregress:' print stats.linregress(l, m) print stats.linregress(a, b) print '\nINFERENTIAL' print 'ttest_1samp:' print stats.ttest_1samp(l, 12) print stats.ttest_1samp(a, 12) print 'ttest_ind:' print stats.ttest_ind(l, m) print stats.ttest_ind(a, b) print 'ttest_rel:' print stats.ttest_rel(l, m) print stats.ttest_rel(a, b) print 'chisquare:' print stats.chisquare(l) print stats.chisquare(a) print 'ks_2samp:' print stats.ks_2samp(l, m) print stats.ks_2samp(a, b) print 'mannwhitneyu:' print stats.mannwhitneyu(l, m) print stats.mannwhitneyu(a, b) print 'ranksums:' print stats.ranksums(l, m) print stats.ranksums(a, b) print 'wilcoxont:'
print(cluster_map) rom scipy import stats diff_exp_high = ((data['CFU'] + data['unk'])/2)/((data['poly'] + data['int'])/2) >= 2 diff_exp_low = ((data['CFU'] + data['unk'])/2)/((data['poly'] + data['int'])/2) <= 0.5 diff_exp_genes = data[diff_exp_high | diff_exp_low] #print(diff_exp_genes) for gene_name, row in diff_exp_genes.iterrows(): sample1 = [row['CFU'], row['unk']] sample2 = [row['poly'], row['int']] # print(gene_name, stats.ttest_rel(sample1, sample2).pvalue) pval = stats.ttest_rel(sample1, sample2).pvalue if pval <= 0.05: print(gene_name, pval) labels = list(kmeans.labels_) genes = list(data.index.values) goi_index = genes.index(sys.argv[2]) goi_cluster = labels[goi_index] related_genes = [] for i, gene in enumerate(genes): if labels[i] == goi_cluster: related_genes.append(gene)