Eliminar graficar_espectro_clusters.jl
This commit is contained in:
@@ -1,71 +0,0 @@
|
||||
|
||||
using MSI_src
|
||||
using CSV, DataFrames
|
||||
using Plots
|
||||
using Statistics
|
||||
using Plots.Measures
|
||||
|
||||
# 1. Carga de datos
|
||||
path_data = "Hoja.imzML"
|
||||
path_mask = "region_interes.png"
|
||||
path_clusters = "msi_clusters_results.csv"
|
||||
|
||||
println("Cargando datos...")
|
||||
data = OpenMSIData(path_data)
|
||||
df_clusters = CSV.read(path_clusters, DataFrame)
|
||||
|
||||
# 2. Obtener Espectro Promedio (Referencia única)
|
||||
mzs_repo, ints_repo = MSI_src.get_average_spectrum(data, mask_path=path_mask)
|
||||
|
||||
# 3. Configurar el gráfico base (Línea gris fina y limpia)
|
||||
p = plot(mzs_repo, ints_repo,
|
||||
linecolor = :darkgray,
|
||||
linewidth = 0.8,
|
||||
label = "Espectro Promedio (Referencia)",
|
||||
xlabel = "m/z",
|
||||
ylabel = "Intensidad Relativa",
|
||||
title = "Mapeo de Clusters sobre Patrón Isotópico",
|
||||
size = (1200, 600),
|
||||
legend = :outerright,
|
||||
grid = false, # Estilo limpio de artículo
|
||||
framestyle = :box, # Marco completo
|
||||
left_margin = 15mm,
|
||||
bottom_margin = 15mm
|
||||
)
|
||||
|
||||
# 4. Paleta de colores distintiva
|
||||
colores_clusters = palette(:tab10)
|
||||
|
||||
# 5. Colorear picos específicos (Sticks)
|
||||
println("Resaltando clusters químicos...")
|
||||
for cluster_id in sort(unique(df_clusters.cluster))
|
||||
df_sub = filter(row -> row.cluster == cluster_id, df_clusters)
|
||||
|
||||
label_listo = false
|
||||
|
||||
for mz_target in df_sub.mz
|
||||
# Buscar el índice del pico real en el promedio
|
||||
idx = argmin(abs.(mzs_repo .- mz_target))
|
||||
|
||||
# Tolerancia para centrar el color en el pico real
|
||||
if abs(mzs_repo[idx] - mz_target) < 0.1
|
||||
m = mzs_repo[idx]
|
||||
i = ints_repo[idx]
|
||||
|
||||
# Dibujar el "stick" del cluster sobre el espectro base
|
||||
plot!(p, [m, m], [0, i],
|
||||
linecolor = colores_clusters[cluster_id + 1],
|
||||
linewidth = 1.2,
|
||||
alpha = 1.0, # Totalmente opaco para destacar
|
||||
label = label_listo ? "" : "Cluster $cluster_id"
|
||||
)
|
||||
label_listo = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# 6. Guardar con alta resolución
|
||||
savefig("espectro_msi_paper_style.png")
|
||||
println("Gráfico final guardado como 'espectro_msi_paper_style.png'")
|
||||
savefig("espectro_msi_clusters_julia.png")
|
||||
println("Gráfico guardado como 'espectro_msi_clusters_julia.png'")
|
||||
Reference in New Issue
Block a user