Update app.py
Browse files29 unmodified lines303132333435472 unmodified lines50850951051151251318 unmodified lines53253353453553653753828 unmodified lines5675685695705715725735 unmodified lines579580581582583584585500 unmodified lines108610871088108929 unmodified linesimport tracebackimport contextlibfrom pathlib import Pathimport numpy as npimport pandas as pd472 unmodified linescoords, method_label = _reduce_dimensions(matrix, method="tsne")plot_df = pd.DataFrame({"x": coords[:, 0], "y": coords[:, 1],"name": [name_of[i] for i in ids],18 unmodified linessymbol_map={"model": "circle", "user": "x-thin"},color_discrete_map=region_color,hover_name="name", hover_data={"region": True, "kind": True, "x": False, "y": False},title=f"λ³μ΄ νλ‘νμΌ 2D μλ² λ© ({method_label}) β λͺ¨λΈ(κ΅κ°λ³) vs μ¬μ©μ μμ΄",)fig.update_traces(marker=dict(size=10, line=dict(width=0.5, color="white")),selector=dict(mode="markers"))28 unmodified lineselse:ax.scatter(row["x"], row["y"], color=color, marker='x', s=70, linewidth=2, label=label)ax.set_xlabel('Dim 1'); ax.set_ylabel('Dim 2')ax.set_title(f'λ³μ΄ νλ‘νμΌ 2D μλ² λ© ({method_label}) β λͺ¨λΈ(κ΅κ°λ³) vs μ¬μ©μ μμ΄')ax.legend(loc='center left', bbox_to_anchor=(1.02, 0.5), fontsize=8, framealpha=0.9)# λ°κΉ₯ μ¬κ°ν ν λ리λ κ²μ μ€μ μΌλ‘ 4λ©΄ λͺ¨λ νμνκ³ , μμͺ½ 격μμ μ νμ μ μ μΌλ‘.for spine in ax.spines.values():5 unmodified linesfig_mpl.tight_layout()paths['results'].mkdir(parents=True, exist_ok=True)out_path = paths['results'] / "03_embedding_model_vs_query.png"fig_mpl.savefig(out_path, dpi=150, bbox_inches='tight')plt.close(fig_mpl)500 unmodified linesdemo.queue(default_concurrency_limit=1)if __name__ == "__main__":demo.launch(css=_GALLERY_TOOLBAR_CSS)29 unmodified lines30313233343536472 unmodified lines50951051151251351451551651751851918 unmodified lines53853954054154254354428 unmodified lines5735745755765775785795 unmodified lines585586587588589590591500 unmodified lines109210931094109529 unmodified linesimport tracebackimport contextlibfrom pathlib import Pathfrom datetime import datetimeimport numpy as npimport pandas as pd472 unmodified linescoords, method_label = _reduce_dimensions(matrix, method="tsne")# μ λͺ©/νμΌλͺ μ μΈ μ 보: Serotype, Gene, μμ± μκ°safe_gene = s.targetGene.replace('/', '-')title_suffix = f"DENV{s.targetSerotype} Β· {s.targetGene}"timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")plot_df = pd.DataFrame({"x": coords[:, 0], "y": coords[:, 1],"name": [name_of[i] for i in ids],18 unmodified linessymbol_map={"model": "circle", "user": "x-thin"},color_discrete_map=region_color,hover_name="name", hover_data={"region": True, "kind": True, "x": False, "y": False},title=f"λ³μ΄ νλ‘νμΌ 2D μλ² λ© ({method_label}) β {title_suffix} β λͺ¨λΈ(κ΅κ°λ³) vs μ¬μ©μ μμ΄",)fig.update_traces(marker=dict(size=10, line=dict(width=0.5, color="white")),selector=dict(mode="markers"))28 unmodified lineselse:ax.scatter(row["x"], row["y"], color=color, marker='x', s=70, linewidth=2, label=label)ax.set_xlabel('Dim 1'); ax.set_ylabel('Dim 2')ax.set_title(f'λ³μ΄ νλ‘νμΌ 2D μλ² λ© ({method_label}) β {title_suffix} β λͺ¨λΈ(κ΅κ°λ³) vs μ¬μ©μ μμ΄')ax.legend(loc='center left', bbox_to_anchor=(1.02, 0.5), fontsize=8, framealpha=0.9)# λ°κΉ₯ μ¬κ°ν ν λ리λ κ²μ μ€μ μΌλ‘ 4λ©΄ λͺ¨λ νμνκ³ , μμͺ½ 격μμ μ νμ μ μ μΌλ‘.for spine in ax.spines.values():5 unmodified linesfig_mpl.tight_layout()paths['results'].mkdir(parents=True, exist_ok=True)out_path = paths['results'] / f"03_embedding_DENV{s.targetSerotype}_{safe_gene}_{timestamp}.png"fig_mpl.savefig(out_path, dpi=150, bbox_inches='tight')plt.close(fig_mpl)500 unmodified linesdemo.queue(default_concurrency_limit=1)if __name__ == "__main__":demo.launch(css=_GALLERY_TOOLBAR_CSS)
app.py+10-4