py2ls 0.2.4.3__py3-none-any.whl → 0.2.4.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- py2ls/.DS_Store +0 -0
- py2ls/.git/index +0 -0
- py2ls/bio.py +1384 -19
- py2ls/data/mygenes_fields_241022.txt +355 -0
- py2ls/ips.py +221 -57
- py2ls/ml2ls.py +1094 -0
- py2ls/netfinder.py +12 -1
- py2ls/plot.py +308 -80
- {py2ls-0.2.4.3.dist-info → py2ls-0.2.4.5.dist-info}/METADATA +1 -1
- {py2ls-0.2.4.3.dist-info → py2ls-0.2.4.5.dist-info}/RECORD +11 -9
- {py2ls-0.2.4.3.dist-info → py2ls-0.2.4.5.dist-info}/WHEEL +0 -0
py2ls/netfinder.py
CHANGED
@@ -742,7 +742,18 @@ def downloader(
|
|
742
742
|
counter_ = str(counter)
|
743
743
|
new_filename = f"{base}_{counter_}{ext}"
|
744
744
|
counter += 1
|
745
|
-
return new_filename
|
745
|
+
return new_filename
|
746
|
+
|
747
|
+
if url.startswith("ftp"):
|
748
|
+
import urllib.request
|
749
|
+
|
750
|
+
if dir_save is None:
|
751
|
+
dir_save = "./"
|
752
|
+
dir_save+= os.path.basename(url)
|
753
|
+
print(dir_save)
|
754
|
+
urllib.request.urlretrieve(url, dir_save)
|
755
|
+
print(f"Downloaded file to: {dir_save}")
|
756
|
+
return None
|
746
757
|
|
747
758
|
fpath_tmp, corrected_fname = None, None
|
748
759
|
if not isinstance(kind, list):
|
py2ls/plot.py
CHANGED
@@ -11,7 +11,7 @@ import logging
|
|
11
11
|
import os
|
12
12
|
import re
|
13
13
|
from typing import Union
|
14
|
-
from .ips import fsave, fload, mkdir, listdir, figsave, strcmp, unique, get_os, ssplit,plt_font
|
14
|
+
from .ips import fsave, fload, mkdir, listdir, figsave, strcmp, unique, get_os, ssplit,plt_font,flatten
|
15
15
|
from .stats import *
|
16
16
|
from .netfinder import get_soup, fetch
|
17
17
|
|
@@ -1897,6 +1897,16 @@ def figsets(*args, **kwargs):
|
|
1897
1897
|
if ("fo" in key) and (("size" in key) or ("sz" in key)):
|
1898
1898
|
fontsize = value
|
1899
1899
|
plt.rcParams.update({"font.size": fontsize})
|
1900
|
+
# Customize tick labels
|
1901
|
+
ax.tick_params(axis='both', which='major', labelsize=fontsize)
|
1902
|
+
for label in ax.get_xticklabels() + ax.get_yticklabels():
|
1903
|
+
label.set_fontname(fontname)
|
1904
|
+
|
1905
|
+
# Optionally adjust legend font properties if a legend is included
|
1906
|
+
if ax.get_legend():
|
1907
|
+
for text in ax.get_legend().get_texts():
|
1908
|
+
text.set_fontsize(fontsize)
|
1909
|
+
text.set_fontname(fontname)
|
1900
1910
|
# style
|
1901
1911
|
if "st" in key.lower() or "th" in key.lower():
|
1902
1912
|
if isinstance(value, str):
|
@@ -2210,6 +2220,9 @@ def figsets(*args, **kwargs):
|
|
2210
2220
|
legend = ax.get_legend()
|
2211
2221
|
if legend is not None:
|
2212
2222
|
legend.remove()
|
2223
|
+
if any(['colorbar' in key.lower(),'cbar' in key.lower()]) and "loc" in key.lower():
|
2224
|
+
cbar = ax.collections[0].colorbar # Access the colorbar from the plot
|
2225
|
+
cbar.ax.set_position(value) # [left, bottom, width, height] [0.475, 0.15, 0.04, 0.25]
|
2213
2226
|
|
2214
2227
|
for arg in args:
|
2215
2228
|
if isinstance(arg, matplotlib.axes._axes.Axes):
|
@@ -2698,15 +2711,45 @@ def adjust_spines(ax=None, spines=["left", "bottom"], distance=2):
|
|
2698
2711
|
# And then plot the data:
|
2699
2712
|
|
2700
2713
|
|
2701
|
-
def add_colorbar(im, width=None, pad=None, **kwargs):
|
2702
|
-
|
2703
|
-
|
2704
|
-
|
2705
|
-
|
2706
|
-
|
2707
|
-
|
2708
|
-
|
2714
|
+
# def add_colorbar(im, width=None, pad=None, **kwargs):
|
2715
|
+
# # usage: add_colorbar(im, width=0.01, pad=0.005, label="PSD (dB)", shrink=0.8)
|
2716
|
+
# l, b, w, h = im.axes.get_position().bounds # get boundaries
|
2717
|
+
# width = width or 0.1 * w # get width of the colorbar
|
2718
|
+
# pad = pad or width # get pad between im and cbar
|
2719
|
+
# fig = im.axes.figure # get figure of image
|
2720
|
+
# cax = fig.add_axes([l + w + pad, b, width, h]) # define cbar Axes
|
2721
|
+
# return fig.colorbar(im, cax=cax, **kwargs) # draw cbar
|
2722
|
+
|
2723
|
+
def add_colorbar(im,
|
2724
|
+
cmap="viridis",
|
2725
|
+
vmin=-1,
|
2726
|
+
vmax=1,
|
2727
|
+
orientation='vertical',
|
2728
|
+
width_ratio=0.05,
|
2729
|
+
pad_ratio=0.02,
|
2730
|
+
shrink=1.0,
|
2731
|
+
**kwargs):
|
2732
|
+
import matplotlib as mpl
|
2733
|
+
if all([cmap, vmin, vmax]):
|
2734
|
+
norm = mpl.colors.Normalize(vmin=vmin, vmax=vmax)
|
2735
|
+
else:
|
2736
|
+
norm=False
|
2737
|
+
sm = plt.cm.ScalarMappable(cmap=cmap, norm=norm)
|
2738
|
+
sm.set_array([])
|
2739
|
+
l, b, w, h = im.axes.get_position().bounds # position: left, bottom, width, height
|
2740
|
+
if orientation == 'vertical':
|
2741
|
+
width = width_ratio * w
|
2742
|
+
pad = pad_ratio * w
|
2743
|
+
cax = im.figure.add_axes([l + w + pad, b, width, h * shrink]) # Right of the image
|
2744
|
+
else:
|
2745
|
+
height = width_ratio * h
|
2746
|
+
pad = pad_ratio * h
|
2747
|
+
cax = im.figure.add_axes([l, b - height - pad, w * shrink, height]) # Below the image
|
2748
|
+
cbar=im.figure.colorbar(sm, cax=cax, orientation=orientation, **kwargs)
|
2749
|
+
return cbar
|
2709
2750
|
|
2751
|
+
# Usage:
|
2752
|
+
# add_colorbar(im, width_ratio=0.03, pad_ratio=0.01, orientation='horizontal', label="PSD (dB)")
|
2710
2753
|
|
2711
2754
|
def generate_xticks_with_gap(x_len, hue_len):
|
2712
2755
|
"""
|
@@ -3119,7 +3162,7 @@ def plotxy(
|
|
3119
3162
|
kws_count = kwargs.pop("kws_count", kwargs)
|
3120
3163
|
if not kws_count.get("hue",None):
|
3121
3164
|
kws_count.pop("palette",None)
|
3122
|
-
ax = sns.countplot(data=data, x=x, ax=ax, **kws_count)
|
3165
|
+
ax = sns.countplot(data=data, x=x,y=y, ax=ax, **kws_count)
|
3123
3166
|
elif k == "regplot":
|
3124
3167
|
kws_reg = kwargs.pop("kws_reg", kwargs)
|
3125
3168
|
ax = sns.regplot(data=data, x=x, y=y, ax=ax, **kws_reg)
|
@@ -3145,15 +3188,20 @@ def plotxy(
|
|
3145
3188
|
return g, ax
|
3146
3189
|
return ax
|
3147
3190
|
|
3191
|
+
def norm_cmap(data, cmap="coolwarm", min_max=[0, 1]):
|
3192
|
+
norm_ = plt.Normalize(min_max[0], min_max[1])
|
3193
|
+
colormap = plt.get_cmap(cmap)
|
3194
|
+
return colormap(norm_(data))
|
3148
3195
|
|
3149
3196
|
def volcano(
|
3150
3197
|
data:pd.DataFrame,
|
3151
3198
|
x:str,
|
3152
3199
|
y:str,
|
3153
|
-
gene_col=None,
|
3200
|
+
gene_col:str=None,
|
3154
3201
|
top_genes=[5, 5], # [down-regulated, up-regulated]
|
3155
|
-
thr_x=np.log2(1.5),
|
3202
|
+
thr_x=np.log2(1.5), # default: 0.585
|
3156
3203
|
thr_y=-np.log10(0.05),
|
3204
|
+
sort_xy="x", #'y'
|
3157
3205
|
colors=("#00BFFF", "#9d9a9a", "#FF3030"),
|
3158
3206
|
s=20,
|
3159
3207
|
fill=True, # plot filled scatter
|
@@ -3169,7 +3217,7 @@ def volcano(
|
|
3169
3217
|
alpha=0.5,
|
3170
3218
|
edgecolor='black',
|
3171
3219
|
boxstyle='round,pad=0.3'),# '{}' to hide
|
3172
|
-
kws_arrow={}
|
3220
|
+
kws_arrow=dict(color="k", lw=0.5),# '{}' to hide
|
3173
3221
|
**kwargs,
|
3174
3222
|
):
|
3175
3223
|
"""
|
@@ -3239,29 +3287,39 @@ def volcano(
|
|
3239
3287
|
kws_figsets = v_arg
|
3240
3288
|
kwargs.pop(k_arg, None)
|
3241
3289
|
break
|
3242
|
-
|
3243
|
-
data
|
3290
|
+
|
3291
|
+
data=data.copy()
|
3292
|
+
# filter nan
|
3293
|
+
data = data.dropna(subset=[x, y]) # Drop rows with NaN in x or y
|
3294
|
+
data.loc[:,"color"] = np.where(
|
3244
3295
|
(data[x] > thr_x) & (data[y] > thr_y),
|
3245
3296
|
colors[2],
|
3246
|
-
np.where((data[x] < -thr_x) & (data[y] > thr_y),
|
3297
|
+
np.where((data[x] < -thr_x) & (data[y] > thr_y),
|
3298
|
+
colors[0],
|
3299
|
+
colors[1]),
|
3247
3300
|
)
|
3248
3301
|
top_genes=[top_genes, top_genes] if isinstance(top_genes,int) else top_genes
|
3302
|
+
|
3303
|
+
# could custom how to select the top genes, x: x has priority
|
3304
|
+
sort_by_x_y=[x,y] if sort_xy=="x" else [y,x]
|
3305
|
+
ascending_up=[True, True] if sort_xy=="x" else [False, True]
|
3306
|
+
ascending_down=[False, True] if sort_xy=="x" else [False, False]
|
3249
3307
|
|
3250
3308
|
down_reg_genes = data[
|
3251
3309
|
(data["color"] == colors[0]) &
|
3252
3310
|
(data[x].abs() > thr_x) &
|
3253
3311
|
(data[y] > thr_y)
|
3254
|
-
].sort_values(by=
|
3255
|
-
|
3256
|
-
# Selecting top upregulated genes based on both p-value and fold change
|
3312
|
+
].sort_values(by=sort_by_x_y, ascending=ascending_up).head(top_genes[0])
|
3257
3313
|
up_reg_genes = data[
|
3258
3314
|
(data["color"] == colors[2]) &
|
3259
3315
|
(data[x].abs() > thr_x) &
|
3260
3316
|
(data[y] > thr_y)
|
3261
|
-
].sort_values(by=
|
3317
|
+
].sort_values(by=sort_by_x_y, ascending=ascending_down).head(top_genes[1])
|
3262
3318
|
sele_gene = pd.concat([down_reg_genes, up_reg_genes])
|
3263
|
-
|
3264
|
-
palette = {colors[0]: colors[0],
|
3319
|
+
|
3320
|
+
palette = {colors[0]: colors[0],
|
3321
|
+
colors[1]: colors[1],
|
3322
|
+
colors[2]: colors[2]}
|
3265
3323
|
# Plot setup
|
3266
3324
|
if ax is None:
|
3267
3325
|
ax = plt.gca()
|
@@ -3279,7 +3337,7 @@ def volcano(
|
|
3279
3337
|
data=data,
|
3280
3338
|
x=x,
|
3281
3339
|
y=y,
|
3282
|
-
|
3340
|
+
hue="color",
|
3283
3341
|
palette=palette,
|
3284
3342
|
s=s,
|
3285
3343
|
linewidths=edgelinewidth,
|
@@ -3298,65 +3356,57 @@ def volcano(
|
|
3298
3356
|
# Add gene labels for selected significant points
|
3299
3357
|
if gene_col:
|
3300
3358
|
texts = []
|
3301
|
-
if kws_text:
|
3302
|
-
|
3303
|
-
|
3304
|
-
|
3305
|
-
|
3306
|
-
|
3307
|
-
|
3308
|
-
|
3309
|
-
|
3310
|
-
|
3311
|
-
|
3312
|
-
|
3313
|
-
|
3314
|
-
|
3315
|
-
|
3316
|
-
|
3317
|
-
|
3318
|
-
|
3319
|
-
|
3320
|
-
|
3321
|
-
|
3322
|
-
|
3323
|
-
|
3324
|
-
|
3325
|
-
|
3326
|
-
|
3327
|
-
|
3328
|
-
|
3329
|
-
|
3330
|
-
|
3331
|
-
|
3332
|
-
|
3333
|
-
)
|
3334
|
-
)
|
3335
|
-
print(arrowstyle)
|
3336
|
-
adjust_text(
|
3337
|
-
texts,
|
3338
|
-
expand=expand,
|
3339
|
-
min_arrow_len=5,
|
3340
|
-
# force_explode=(0.1, 0.5),
|
3341
|
-
# force_text=(0.1, 0.5),
|
3342
|
-
# force_points=(0.1, 0.5),
|
3343
|
-
# explode_radius=10,
|
3344
|
-
# expand_text=(1, 1),
|
3345
|
-
# expand_points=(1, 1),
|
3346
|
-
# ha='center',
|
3347
|
-
# va='top',
|
3348
|
-
ax=ax,
|
3349
|
-
arrowprops=dict(
|
3350
|
-
arrowstyle=arrowstyle,
|
3351
|
-
fill=arrow_fill,
|
3352
|
-
color=arrowcolor,
|
3353
|
-
lw=arrowlinewidth,
|
3354
|
-
shrinkA=shrinkA,
|
3355
|
-
shrinkB=shrinkB,
|
3356
|
-
mutation_scale=mutation_scale,
|
3357
|
-
**kws_arrow,
|
3359
|
+
# if kws_text:
|
3360
|
+
fontname = kws_text.pop("fontname", "Arial")
|
3361
|
+
textcolor = kws_text.pop("color", "k")
|
3362
|
+
fontsize = kws_text.pop("fontsize", 10)
|
3363
|
+
arrowstyles = [
|
3364
|
+
"->","<-","<->","<|-","-|>","<|-|>",
|
3365
|
+
"-","-[","-[",
|
3366
|
+
"fancy","simple","wedge",
|
3367
|
+
]
|
3368
|
+
arrowstyle = kws_arrow.pop("style", "<|-")
|
3369
|
+
arrowstyle = strcmp(arrowstyle, arrowstyles,scorer='strict')[0]
|
3370
|
+
expand=kws_arrow.pop("expand",(1.05,1.1))
|
3371
|
+
arrowcolor = kws_arrow.pop("color", "0.4")
|
3372
|
+
arrowlinewidth = kws_arrow.pop("lw", 0.75)
|
3373
|
+
shrinkA = kws_arrow.pop("shrinkA", 0)
|
3374
|
+
shrinkB = kws_arrow.pop("shrinkB", 0)
|
3375
|
+
mutation_scale = kws_arrow.pop("head", 10)
|
3376
|
+
arrow_fill=kws_arrow.pop("fill", False)
|
3377
|
+
for i in range(sele_gene.shape[0]):
|
3378
|
+
if isinstance(textcolor, list): # be consistant with dots's color
|
3379
|
+
textcolor = colors[0] if sele_gene[x].iloc[i] > 0 else colors[1]
|
3380
|
+
texts.append(
|
3381
|
+
ax.text(
|
3382
|
+
x=sele_gene[x].iloc[i],
|
3383
|
+
y=sele_gene[y].iloc[i],
|
3384
|
+
s=sele_gene[gene_col].iloc[i],
|
3385
|
+
bbox=kws_bbox if kws_bbox else None,
|
3386
|
+
fontdict={
|
3387
|
+
"fontsize": fontsize,
|
3388
|
+
"color": textcolor,
|
3389
|
+
"fontname": fontname,
|
3390
|
+
},
|
3358
3391
|
)
|
3359
3392
|
)
|
3393
|
+
print(arrowstyle)
|
3394
|
+
adjust_text(
|
3395
|
+
texts,
|
3396
|
+
expand=expand,
|
3397
|
+
min_arrow_len=5,
|
3398
|
+
ax=ax,
|
3399
|
+
arrowprops=dict(
|
3400
|
+
arrowstyle=arrowstyle,
|
3401
|
+
fill=arrow_fill,
|
3402
|
+
color=arrowcolor,
|
3403
|
+
lw=arrowlinewidth,
|
3404
|
+
shrinkA=shrinkA,
|
3405
|
+
shrinkB=shrinkB,
|
3406
|
+
mutation_scale=mutation_scale,
|
3407
|
+
**kws_arrow,
|
3408
|
+
)
|
3409
|
+
)
|
3360
3410
|
|
3361
3411
|
figsets(**kws_figsets)
|
3362
3412
|
|
@@ -3446,3 +3496,181 @@ def sns_func_info(dir_save=None):
|
|
3446
3496
|
dir_save + "sns_info.json",
|
3447
3497
|
sns_info,
|
3448
3498
|
)
|
3499
|
+
|
3500
|
+
|
3501
|
+
|
3502
|
+
|
3503
|
+
|
3504
|
+
|
3505
|
+
def venn(
|
3506
|
+
lists:list,
|
3507
|
+
labels:list,
|
3508
|
+
ax=None,
|
3509
|
+
colors=None,
|
3510
|
+
edgecolor="0.25",
|
3511
|
+
alpha=0.75,
|
3512
|
+
linewidth=.75,
|
3513
|
+
linestyle="-",
|
3514
|
+
fontname='Arial',
|
3515
|
+
fontsize=11,
|
3516
|
+
fontweight="normal",
|
3517
|
+
fontstyle="normal",
|
3518
|
+
label_align="center",
|
3519
|
+
label_baseline="center",
|
3520
|
+
subset_fontsize=9,
|
3521
|
+
subset_fontweight="normal",
|
3522
|
+
subset_fontstyle="normal",
|
3523
|
+
subset_label_format="{:d}",
|
3524
|
+
shadow=False,
|
3525
|
+
custom_texts=None,
|
3526
|
+
hatches=None,
|
3527
|
+
per_circle_styles=None,
|
3528
|
+
**kwargs
|
3529
|
+
):
|
3530
|
+
"""
|
3531
|
+
Advanced Venn diagram plotting function with extensive customization options.
|
3532
|
+
|
3533
|
+
Parameters:
|
3534
|
+
lists: list of sets, 2 or 3 sets
|
3535
|
+
labels: list of strings, labels for the sets
|
3536
|
+
ax: matplotlib axis, optional
|
3537
|
+
colors: list of colors, colors for the Venn diagram patches
|
3538
|
+
edgecolor: string, color of the circle edges
|
3539
|
+
alpha: float, transparency level for the patches
|
3540
|
+
linewidth: float, width of the circle edges
|
3541
|
+
linestyle: string, line style for the circles
|
3542
|
+
fontname: string, font for set labels
|
3543
|
+
fontsize: int, font size for set labels
|
3544
|
+
fontweight: string, weight of the set label font (e.g., 'bold', 'light')
|
3545
|
+
fontstyle: string, style of the set label font (e.g., 'italic')
|
3546
|
+
label_align: string, horizontal alignment of set labels ('left', 'center', 'right')
|
3547
|
+
label_baseline: string, vertical alignment of set labels ('top', 'center', 'bottom')
|
3548
|
+
subset_fontsize: int, font size for subset labels (the numbers)
|
3549
|
+
subset_fontweight: string, weight of subset label font
|
3550
|
+
subset_fontstyle: string, style of subset label font
|
3551
|
+
subset_label_format: string, format for subset labels (e.g., "{:.2f}" for floats)
|
3552
|
+
shadow: bool, add shadow effect to the patches
|
3553
|
+
custom_texts: list of custom texts to replace the subset labels
|
3554
|
+
hatches: list of hatch patterns for the patches
|
3555
|
+
per_circle_styles: dict, custom styles for each circle (e.g., {'circle_1': {'color': 'red'}})
|
3556
|
+
**kwargs: additional keyword arguments passed to venn2 or venn3
|
3557
|
+
"""
|
3558
|
+
if ax is None:
|
3559
|
+
ax = plt.gca()
|
3560
|
+
lists=[set(flatten(i, verbose=False)) for i in lists]
|
3561
|
+
# Function to apply text styles to labels
|
3562
|
+
def apply_text_style(text, fontname, fontsize, fontweight, fontstyle):
|
3563
|
+
if text: # Ensure text exists
|
3564
|
+
if fontname:
|
3565
|
+
text.set_fontname(fontname)
|
3566
|
+
if fontsize:
|
3567
|
+
text.set_fontsize(fontsize)
|
3568
|
+
if fontweight:
|
3569
|
+
text.set_fontweight(fontweight)
|
3570
|
+
if fontstyle:
|
3571
|
+
text.set_fontstyle(fontstyle)
|
3572
|
+
# Alignment customization
|
3573
|
+
text.set_horizontalalignment(label_align)
|
3574
|
+
text.set_verticalalignment(label_baseline)
|
3575
|
+
|
3576
|
+
if len(lists) == 2:
|
3577
|
+
from matplotlib_venn import venn2, venn2_circles
|
3578
|
+
v = venn2(subsets=lists, set_labels=labels, ax=ax, **kwargs)
|
3579
|
+
venn_circles = venn2_circles(subsets=lists, ax=ax,color=edgecolor)
|
3580
|
+
if not isinstance(linewidth,list):
|
3581
|
+
linewidth=[linewidth]
|
3582
|
+
if isinstance(linestyle,str):
|
3583
|
+
linestyle=[linestyle]
|
3584
|
+
linewidth=linewidth*2 if len(linewidth)==1 else linewidth
|
3585
|
+
linestyle=linestyle*2 if len(linestyle)==1 else linestyle
|
3586
|
+
for i in range(2):
|
3587
|
+
venn_circles[i].set_lw(linewidth[i])
|
3588
|
+
venn_circles[i].set_ls(linestyle[i])
|
3589
|
+
# Apply styles to set labels
|
3590
|
+
for i, text in enumerate(v.set_labels):
|
3591
|
+
apply_text_style(text, fontname, fontsize, fontweight, fontstyle)
|
3592
|
+
|
3593
|
+
# Apply styles to subset labels
|
3594
|
+
for i, text in enumerate(v.subset_labels):
|
3595
|
+
if text: # Ensure text exists
|
3596
|
+
if custom_texts: # Custom text handling
|
3597
|
+
text.set_text(custom_texts[i])
|
3598
|
+
else: # Default subset label formatting
|
3599
|
+
subset_size = (
|
3600
|
+
len(lists[i % 2])
|
3601
|
+
if i in [0, 1]
|
3602
|
+
else len(lists[0].intersection(lists[1]))
|
3603
|
+
)
|
3604
|
+
text.set_text(subset_label_format.format(subset_size))
|
3605
|
+
apply_text_style(
|
3606
|
+
text, None, subset_fontsize, subset_fontweight, subset_fontstyle
|
3607
|
+
)
|
3608
|
+
elif len(lists) == 3:
|
3609
|
+
from matplotlib_venn import venn3, venn3_circles
|
3610
|
+
v = venn3(
|
3611
|
+
subsets=lists, set_labels=labels, set_colors=colors, ax=ax, **kwargs
|
3612
|
+
)
|
3613
|
+
venn_circles = venn3_circles(
|
3614
|
+
subsets=lists, ax=ax,color=edgecolor
|
3615
|
+
)
|
3616
|
+
if not isinstance(linewidth,list):
|
3617
|
+
linewidth=[linewidth]
|
3618
|
+
if isinstance(linestyle,str):
|
3619
|
+
linestyle=[linestyle]
|
3620
|
+
linewidth=linewidth*3 if len(linewidth)==1 else linewidth
|
3621
|
+
linestyle=linestyle*3 if len(linestyle)==1 else linestyle
|
3622
|
+
for i in range(3):
|
3623
|
+
venn_circles[i].set_lw(linewidth[i])
|
3624
|
+
venn_circles[i].set_ls(linestyle[i])
|
3625
|
+
|
3626
|
+
# Apply styles to set labels
|
3627
|
+
for i, text in enumerate(v.set_labels):
|
3628
|
+
apply_text_style(text, fontname, fontsize, fontweight, fontstyle)
|
3629
|
+
|
3630
|
+
# Apply styles to subset labels
|
3631
|
+
for i, text in enumerate(v.subset_labels):
|
3632
|
+
if text: # Ensure text exists
|
3633
|
+
if custom_texts: # Custom text handling
|
3634
|
+
text.set_text(custom_texts[i])
|
3635
|
+
else: # Default subset label formatting
|
3636
|
+
subset_size = (
|
3637
|
+
len(lists[i])
|
3638
|
+
if i < 3
|
3639
|
+
else len(lists[0].intersection(lists[1], lists[2]))
|
3640
|
+
)
|
3641
|
+
text.set_text(subset_label_format.format(subset_size))
|
3642
|
+
apply_text_style(
|
3643
|
+
text, None, subset_fontsize, subset_fontweight, subset_fontstyle
|
3644
|
+
)
|
3645
|
+
else:
|
3646
|
+
raise ValueError("只支持2或者3个list")
|
3647
|
+
# Set circle and patch customizations (edge color, transparency, hatches)
|
3648
|
+
for i, patch in enumerate(v.patches):
|
3649
|
+
if patch:
|
3650
|
+
if colors:
|
3651
|
+
patch.set_facecolor(colors[i % len(colors)])
|
3652
|
+
patch.set_edgecolor("none")
|
3653
|
+
patch.set_alpha(alpha)
|
3654
|
+
if hatches:
|
3655
|
+
patch.set_hatch(hatches[i % len(hatches)])
|
3656
|
+
if shadow:
|
3657
|
+
from matplotlib.patches import Shadow
|
3658
|
+
shadow_patch = Shadow(patch, -0.02, -0.02, alpha=0.2)
|
3659
|
+
ax.add_patch(shadow_patch)
|
3660
|
+
# # usage:
|
3661
|
+
# venn(
|
3662
|
+
# [rf_features, svm_features, lasso_features],
|
3663
|
+
# ["Random Forest", "SVM-RFE", "a"],
|
3664
|
+
# ax=axs[0], # Specify the axes
|
3665
|
+
# colors=["#BDC8E0", "#E5C0C1", "#D0E9CB"],
|
3666
|
+
# edgecolor="r",
|
3667
|
+
# alpha=1,
|
3668
|
+
# linewidth=[1, 2, 18],# 分别设置字体大小
|
3669
|
+
# linestyle=["-", "--", ":"],
|
3670
|
+
# fontsize=20,
|
3671
|
+
# label_baseline="top",
|
3672
|
+
# subset_label_format="{:.2f}%",
|
3673
|
+
# subset_fontsize=18,
|
3674
|
+
# shadow=False,
|
3675
|
+
# # custom_texts=["a", "b", "c"],
|
3676
|
+
# )
|
@@ -1,4 +1,4 @@
|
|
1
|
-
py2ls/.DS_Store,sha256=
|
1
|
+
py2ls/.DS_Store,sha256=JdpMN4cmDCbGxELP0b4LUPASIOzoxopMYybGVl8zlZ0,6148
|
2
2
|
py2ls/.git/COMMIT_EDITMSG,sha256=AdtqRHle5Ej2EBNPJY79v-SB454v5UK4wuPCPFELiFQ,11
|
3
3
|
py2ls/.git/FETCH_HEAD,sha256=VM-2Jiw6iPaGu0ftg9xwq76OyNPWV0iT1nL0VWiL1zI,100
|
4
4
|
py2ls/.git/HEAD,sha256=KNJb-Cr0wOK3L1CVmyvrhZ4-YLljCl6MYD2tTdsrboA,21
|
@@ -17,7 +17,7 @@ py2ls/.git/hooks/pre-receive.sample,sha256=pMPSuce7P9jRRBwxvU7nGlldZrRPz0ndsxAlI
|
|
17
17
|
py2ls/.git/hooks/prepare-commit-msg.sample,sha256=6d3KpBif3dJe2X_Ix4nsp7bKFjkLI5KuMnbwyOGqRhk,1492
|
18
18
|
py2ls/.git/hooks/push-to-checkout.sample,sha256=pT0HQXmLKHxt16-mSu5HPzBeZdP0lGO7nXQI7DsSv18,2783
|
19
19
|
py2ls/.git/hooks/update.sample,sha256=jV8vqD4QPPCLV-qmdSHfkZT0XL28s32lKtWGCXoU0QY,3650
|
20
|
-
py2ls/.git/index,sha256=
|
20
|
+
py2ls/.git/index,sha256=O4t8fvweL1JsEypzrWigO2hAxCpfQwC4VOW3q8panRk,4232
|
21
21
|
py2ls/.git/info/exclude,sha256=ZnH-g7egfIky7okWTR8nk7IxgFjri5jcXAbuClo7DsE,240
|
22
22
|
py2ls/.git/logs/HEAD,sha256=8ID7WuAe_TlO9g-ARxhIJYdgdL3u3m7-1qrOanaIUlA,3535
|
23
23
|
py2ls/.git/logs/refs/heads/main,sha256=8ID7WuAe_TlO9g-ARxhIJYdgdL3u3m7-1qrOanaIUlA,3535
|
@@ -173,7 +173,7 @@ py2ls/LICENSE,sha256=UOZ1F5fFDe3XXvG4oNnkL1-Ecun7zpHzRxjp-XsMeAo,11324
|
|
173
173
|
py2ls/README.md,sha256=CwvJWAnSXnCnrVHlnEbrxxi6MbjbE_MT6DH2D53S818,11572
|
174
174
|
py2ls/__init__.py,sha256=Nn8jTIvySX7t7DMJ8VNRVctTStgXGjHldOIdZ35PdW8,165
|
175
175
|
py2ls/batman.py,sha256=E7gYofbDzN7S5oCmO_dd5Z1bxxhoYMJSD6s-VaF388E,11398
|
176
|
-
py2ls/bio.py,sha256=
|
176
|
+
py2ls/bio.py,sha256=7q-zIxGU76g9AABUcrCLW2GrowTw-ljN_8zKbjdi7p0,67677
|
177
177
|
py2ls/brain_atlas.py,sha256=w1o5EelRjq89zuFJUNSz4Da8HnTCwAwDAZ4NU4a-bAY,5486
|
178
178
|
py2ls/chat.py,sha256=Yr22GoIvoWhpV3m4fdwV_I0Mn77La346_ymSinR-ORA,3793
|
179
179
|
py2ls/correlators.py,sha256=RbOaJIPLCHJtUm5SFi_4dCJ7VFUPWR0PErfK3K26ad4,18243
|
@@ -182,6 +182,7 @@ py2ls/data/db2ls_sql_chtsht.json,sha256=ls9d7Sm8TLeujanWHfHlWhU85Qz1KnAizO_9X3wU
|
|
182
182
|
py2ls/data/docs_links.json,sha256=kXgbbWo0b8bfV4n6iuuUNLnZipIyLzokUO6Lzmf7nO4,101829
|
183
183
|
py2ls/data/email/email_html_template.html,sha256=UIg3aixWfdNsvVx-j2dX1M5N3G-6DgrnV1Ya1cLjiUQ,2809
|
184
184
|
py2ls/data/lang_code_iso639.json,sha256=qZiU7H2RLJjDMXK22C-jhwzLJCI5vKmampjB1ys4ek4,2157
|
185
|
+
py2ls/data/mygenes_fields_241022.txt,sha256=-7htEdtmqbSRTUKHHVmjUFLBwZZg9u3LFpn9OZMb1qg,11348
|
185
186
|
py2ls/data/sns_info.json,sha256=pEzdg2bhMkwQHZpXx02_7zAP7NvRoCc0Le8PN6Uv0Vk,4074
|
186
187
|
py2ls/data/styles/example/style1.pdf,sha256=Pt_qQJ5kiCSIPiz3TWSwEffHUdj75kKXnZ4MPqpEx4I,29873
|
187
188
|
py2ls/data/styles/example/style2.pdf,sha256=0xduPLPulET38LEP2V2H_q70wqlrrBEo8ttqO-FMrfQ,25449
|
@@ -213,15 +214,16 @@ py2ls/export_requirements.py,sha256=x2WgUF0jYKz9GfA1MVKN-MdsM-oQ8yUeC6Ua8oCymio,
|
|
213
214
|
py2ls/fetch_update.py,sha256=9LXj661GpCEFII2wx_99aINYctDiHni6DOruDs_fdt8,4752
|
214
215
|
py2ls/freqanalysis.py,sha256=F4218VSPbgL5tnngh6xNCYuNnfR-F_QjECUUxrPYZss,32594
|
215
216
|
py2ls/ich2ls.py,sha256=3E9R8oVpyYZXH5PiIQgT3CN5NxLe4Dwtm2LwaeacE6I,21381
|
216
|
-
py2ls/ips.py,sha256=
|
217
|
-
py2ls/
|
217
|
+
py2ls/ips.py,sha256=4CmSK5Ye4eHPSkTbrbS9KZ20mz-GA7xw2vEa1o1fI4k,227789
|
218
|
+
py2ls/ml2ls.py,sha256=XSe2-sLNzUVSvVRkeRGfhrB_q8C49SDK1sekYC1Bats,50277
|
219
|
+
py2ls/netfinder.py,sha256=RJFr80tGEJiuwEx99IBOhI5-ZuXnPdWnGUYpF7XCEwI,56426
|
218
220
|
py2ls/ocr.py,sha256=5lhUbJufIKRSOL6wAWVLEo8TqMYSjoI_Q-IO-_4u3DE,31419
|
219
|
-
py2ls/plot.py,sha256=
|
221
|
+
py2ls/plot.py,sha256=h-pcdlQN7Aqqgxw52Rsq5Wvu8LzgiYwO1F6CBvKpTkg,145989
|
220
222
|
py2ls/setuptools-70.1.0-py3-none-any.whl,sha256=2bi3cUVal8ip86s0SOvgspteEF8SKLukECi-EWmFomc,882588
|
221
223
|
py2ls/sleep_events_detectors.py,sha256=bQA3HJqv5qnYKJJEIhCyhlDtkXQfIzqksnD0YRXso68,52145
|
222
224
|
py2ls/stats.py,sha256=DMoJd8Z5YV9T1wB-4P52F5K5scfVK55DT8UP4Twcebo,38627
|
223
225
|
py2ls/translator.py,sha256=zBeq4pYZeroqw3DT-5g7uHfVqKd-EQptT6LJ-Adi8JY,34244
|
224
226
|
py2ls/wb_detector.py,sha256=7y6TmBUj9exCZeIgBAJ_9hwuhkDh1x_-yg4dvNY1_GQ,6284
|
225
|
-
py2ls-0.2.4.
|
226
|
-
py2ls-0.2.4.
|
227
|
-
py2ls-0.2.4.
|
227
|
+
py2ls-0.2.4.5.dist-info/METADATA,sha256=z1aLD2Jcfn3klBZIptJYjHcdwMRZ4hOe9GdjsmI8bBU,20038
|
228
|
+
py2ls-0.2.4.5.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
229
|
+
py2ls-0.2.4.5.dist-info/RECORD,,
|
File without changes
|