softwareDevelopment commited on
Commit
6687151
Β·
verified Β·
1 Parent(s): 0712af0

Update app.R

Browse files
Files changed (1) hide show
  1. app.R +67 -62
app.R CHANGED
@@ -528,63 +528,85 @@ build_all_markers_positions <- function(df_orig, removal_log, linkage_map) {
528
  }
529
 
530
  # ═══════════════════════════════════════════════════════════════════════════════
531
- # CYTOGENETIC PLOT DATA BUILDER
532
  # ═══════════════════════════════════════════════════════════════════════════════
533
 
534
  build_cyto_plot_data <- function(linkage_map, df_retained, selected_chromosomes) {
535
  if (is.null(selected_chromosomes) || length(selected_chromosomes) == 0) return(list())
536
-
 
 
 
 
 
 
 
 
537
  chr_sorted <- tryCatch(
538
  selected_chromosomes[order(as.numeric(selected_chromosomes))],
539
  warning = function(w) sort(selected_chromosomes),
540
  error = function(e) sort(selected_chromosomes)
541
  )
542
-
543
- geno_cols <- setdiff(colnames(df_retained),
544
- c("Marker", "Chromosome", ".input_order", "Position",
545
- "Status", "Reason", "Detail"))
546
-
547
  result <- list()
548
  for (chr in chr_sorted) {
 
549
  sub_map <- linkage_map[linkage_map$Chromosome == chr & !is.na(linkage_map$Position), ]
550
  if (nrow(sub_map) == 0) next
551
  sub_map <- sub_map[order(sub_map$Position), ]
 
 
552
  sub_geno <- df_retained[df_retained$Marker %in% sub_map$Marker, ]
553
-
554
- marker_data <- lapply(seq_len(nrow(sub_map)), function(i) {
555
- mk <- sub_map$Marker[i]
 
556
  pos <- sub_map$Position[i]
557
- geno_row <- sub_geno[sub_geno$Marker == mk, geno_cols, drop=FALSE]
 
 
 
558
  if (nrow(geno_row) == 0 || length(geno_cols) == 0) {
559
- return(list(marker=mk, position=round(pos,3),
560
- allele_a=0, allele_b=0, allele_ab=0, allele_miss=1))
 
 
 
 
 
 
 
561
  }
 
562
  vals <- unlist(geno_row)
563
  vals <- vals[!is.na(vals)]
564
  n_total <- length(vals)
565
  if (n_total == 0) n_total <- 1
566
- list(
567
- marker = mk,
568
- position = round(pos, 3),
569
- allele_a = round(sum(vals == "a") / n_total, 4),
570
- allele_b = round(sum(vals == "b") / n_total, 4),
571
- allele_ab = round(sum(vals == "ab") / n_total, 4),
572
- allele_miss = round(sum(!(vals %in% c("a","b","ab"))) / n_total, 4)
 
573
  )
574
- })
575
-
576
- result[[chr]] <- list(
577
- chromosome = chr,
578
- max_pos = round(max(sub_map$Position), 2),
579
- n_markers = nrow(sub_map),
580
- markers = marker_data
581
- )
 
 
582
  }
583
  result
584
  }
585
 
586
  # ═══════════════════════════════════════════════════════════════════════════════
587
- # HIGH-RESOLUTION GGPLOT LINKAGE MAP (FIXED & ENHANCED)
588
  # ═══════════════════════════════════════════════════════════════════════════════
589
 
590
  create_ggplot_linkage_map <- function(linkage_map,
@@ -783,7 +805,7 @@ create_ggplot_linkage_map <- function(linkage_map,
783
  }
784
 
785
  # ═════════════════════════════���═════════════════════════════════════════════════
786
- # RECOMBINATION HEATMAP (NEW)
787
  # ═══════════════════════════════════════════════════════════════════════════════
788
 
789
  create_recombination_heatmap <- function(rec_data, selected_chr, top_n = 60) {
@@ -833,7 +855,7 @@ create_recombination_heatmap <- function(rec_data, selected_chr, top_n = 60) {
833
  }
834
 
835
  # ═══════════════════════════════════════════════════════════════════════════════
836
- # MARKER DENSITY PLOT (NEW)
837
  # ═══════════════════════════════════════════════════════════════════════════════
838
 
839
  create_marker_density_plot <- function(linkage_map, selected_chr, bin_width = 10) {
@@ -894,7 +916,6 @@ create_marker_density_plot <- function(linkage_map, selected_chr, bin_width = 10
894
 
895
  ui <- fluidPage(
896
  tags$head(
897
- tags$script(src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"),
898
  tags$style(HTML("
899
  @import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap');
900
 
@@ -907,7 +928,6 @@ ui <- fluidPage(
907
  margin: 0; padding-bottom: 60px;
908
  }
909
 
910
- /* ── Navbar ── */
911
  .navbar-default {
912
  background: linear-gradient(135deg, #0F172A 0%, #1E3A8A 60%, #1D4ED8 100%) !important;
913
  border: none !important;
@@ -939,7 +959,6 @@ ui <- fluidPage(
939
  border-bottom: 3px solid #818CF8;
940
  }
941
 
942
- /* ── Cards ── */
943
  .card {
944
  background: #fff;
945
  border-radius: 12px;
@@ -956,7 +975,6 @@ ui <- fluidPage(
956
  }
957
  .card h4 { font-size: 14px; font-weight: 600; color: #3B4FCC; margin: 16px 0 10px; }
958
 
959
- /* ── Sidebar ── */
960
  .well {
961
  background: #fff;
962
  border: 1px solid #E2E8F0;
@@ -965,7 +983,6 @@ ui <- fluidPage(
965
  padding: 18px;
966
  }
967
 
968
- /* ── Controls ── */
969
  .form-control {
970
  border: 1.5px solid #CBD5E1;
971
  border-radius: 8px;
@@ -980,7 +997,6 @@ ui <- fluidPage(
980
  .irs--shiny .irs-handle { background: #6366F1; border-color: #4F46E5; }
981
  .irs--shiny .irs-from, .irs--shiny .irs-to, .irs--shiny .irs-single { background: #4F46E5; }
982
 
983
- /* ── Buttons ── */
984
  .btn {
985
  border-radius: 8px;
986
  font-family: 'DM Sans', sans-serif;
@@ -1012,7 +1028,6 @@ ui <- fluidPage(
1012
  }
1013
  .btn-block { width: 100%; display: block; }
1014
 
1015
- /* ── Alert banners ── */
1016
  .alert-info {
1017
  background: #EFF6FF; border: 1px solid #BFDBFE;
1018
  color: #1E40AF; border-radius: 10px; font-size: 13px;
@@ -1026,7 +1041,6 @@ ui <- fluidPage(
1026
  color: #065F46; border-radius: 10px; font-size: 13px;
1027
  }
1028
 
1029
- /* ── Plot containers ── */
1030
  .plot-wrapper {
1031
  background: #fff;
1032
  border-radius: 12px;
@@ -1035,7 +1049,6 @@ ui <- fluidPage(
1035
  box-shadow: 0 4px 20px rgba(30,58,138,0.08);
1036
  }
1037
 
1038
- /* ── Cytogenetic canvas ── */
1039
  #cyto-scroll-wrapper {
1040
  overflow-x: auto; overflow-y: hidden;
1041
  background: #fff;
@@ -1047,7 +1060,7 @@ ui <- fluidPage(
1047
  #cytoCanvas {
1048
  display: block;
1049
  cursor: crosshair;
1050
- image-rendering: -webkit-optimize-contrast;
1051
  }
1052
  #cyto-tooltip {
1053
  position: fixed;
@@ -1087,7 +1100,6 @@ ui <- fluidPage(
1087
  .legend-item { display: flex; align-items: center; gap: 7px; font-weight: 500; }
1088
  .legend-swatch { width: 18px; height: 18px; border-radius: 4px; border: 1px solid rgba(0,0,0,0.1); }
1089
 
1090
- /* ── Tables ── */
1091
  .dataTables_wrapper { font-size: 13px; }
1092
  table.dataTable { border: 1px solid #E2E8F0 !important; border-radius: 8px; }
1093
  table.dataTable thead th {
@@ -1098,10 +1110,8 @@ ui <- fluidPage(
1098
  }
1099
  table.dataTable tbody tr:hover { background: #EEF2FF !important; }
1100
 
1101
- /* ── Code output ── */
1102
  pre { font-family: 'JetBrains Mono', monospace; font-size: 12px; background: #F1F5F9; border-radius: 8px; border: 1px solid #E2E8F0; }
1103
 
1104
- /* ── Footer ── */
1105
  .footer {
1106
  position: fixed; bottom: 0; width: 100%;
1107
  background: linear-gradient(90deg, #0F172A, #1E3A8A);
@@ -1111,7 +1121,6 @@ ui <- fluidPage(
1111
  z-index: 100;
1112
  }
1113
 
1114
- /* ── Chi-square panels ── */
1115
  .chi-panel {
1116
  background: #F0FDF4; border: 1px solid #86EFAC;
1117
  border-radius: 8px; padding: 14px; margin-top: 10px;
@@ -1122,7 +1131,6 @@ ui <- fluidPage(
1122
  font-size: 12px; color: #991B1B;
1123
  }
1124
 
1125
- /* ── Stat badges ── */
1126
  .stat-badge {
1127
  display: inline-flex; align-items: center; justify-content: center;
1128
  background: linear-gradient(135deg,#EEF2FF,#DBEAFE);
@@ -1141,7 +1149,6 @@ ui <- fluidPage(
1141
  id = "nav",
1142
  collapsible = TRUE,
1143
 
1144
- # ── Tab 1: Upload ──────────────────────────────────────────────────────
1145
  tabPanel("πŸ“ Upload", icon = icon("upload"),
1146
  sidebarLayout(
1147
  sidebarPanel(width = 4,
@@ -1157,11 +1164,11 @@ ui <- fluidPage(
1157
  hr(),
1158
  div(class = "alert alert-info",
1159
  tags$b("✨ v6.0 Features:"), br(),
1160
- "β€’ High-resolution ggplot linkage map (dark/white/blue theme)", br(),
1161
  "β€’ Recombination fraction heatmap", br(),
1162
  "β€’ Marker density distribution plot", br(),
1163
  "β€’ Cytogenetic ideogram with hover tooltips", br(),
1164
- "β€’ Allele frequency pie charts per chromosome", br(),
1165
  "β€’ Full Excel export with all analysis sheets"
1166
  )
1167
  )
@@ -1183,7 +1190,6 @@ ui <- fluidPage(
1183
  )
1184
  ),
1185
 
1186
- # ── Tab 2: Parameters ──────────────────────────────────────────────────
1187
  tabPanel("βš™οΈ Parameters", icon = icon("sliders-h"),
1188
  sidebarLayout(
1189
  sidebarPanel(width = 4,
@@ -1242,7 +1248,6 @@ ui <- fluidPage(
1242
  )
1243
  ),
1244
 
1245
- # ── Tab 3: QC Report ───────────────────────────────────────────────────
1246
  tabPanel("πŸ” QC Report", icon = icon("clipboard-check"),
1247
  div(class="card",
1248
  h3("πŸ“‹ Quality Control Report"),
@@ -1257,7 +1262,6 @@ ui <- fluidPage(
1257
  )
1258
  ),
1259
 
1260
- # ── Tab 4: Results ─────────────────────────────────────────────────────
1261
  tabPanel("πŸ“Š Results", icon = icon("table"),
1262
  div(class="card",
1263
  h3("πŸ“Š Analysis Results"),
@@ -1293,7 +1297,6 @@ ui <- fluidPage(
1293
  )
1294
  ),
1295
 
1296
- # ── Tab 5: Linkage Map Plot ────────────────────────────────────────────
1297
  tabPanel("πŸ—ΊοΈ Map Plot", icon = icon("chart-bar"),
1298
  sidebarLayout(
1299
  sidebarPanel(width = 3,
@@ -1335,7 +1338,6 @@ ui <- fluidPage(
1335
  )
1336
  ),
1337
 
1338
- # ── Tab 6: Density & Heatmap ───────────────────────────────────────────
1339
  tabPanel("πŸ“‰ Density & RF", icon = icon("chart-area"),
1340
  fluidRow(
1341
  column(12,
@@ -1381,7 +1383,6 @@ ui <- fluidPage(
1381
  )
1382
  ),
1383
 
1384
- # ── Tab 7: Cytogenetic Plot ────────────────────────────────────────────
1385
  tabPanel("🧬 Cytogenetic", icon = icon("dna"),
1386
  div(class="card",
1387
  h3("🧬 High-Resolution Cytogenetic Ideogram"),
@@ -1421,8 +1422,6 @@ ui <- fluidPage(
1421
  style="background:rgba(148,163,184,0.4); border:1px dashed #94A3B8;"),
1422
  tags$span("Missing / unknown"))
1423
  ),
1424
-
1425
- # ── Cytogenetic plot controls ──────────────────────────────────
1426
  br(),
1427
  fluidRow(
1428
  column(3, sliderInput("cyto_chrom_width", "Chromosome Width:",
@@ -1452,7 +1451,6 @@ ui <- fluidPage(
1452
  )
1453
  ),
1454
 
1455
- # ── Tab 8: Help ────────────────────────────────────────────────────────
1456
  tabPanel("❓ Help", icon = icon("question-circle"),
1457
  div(class="card",
1458
  h3("πŸ“– Application Guide β€” v6.0"),
@@ -1485,10 +1483,8 @@ ui <- fluidPage(
1485
  )
1486
  ),
1487
 
1488
- # ── Tooltip ──────────────────────────────────────────────────────────────
1489
  div(id = "cyto-tooltip"),
1490
 
1491
- # ── JavaScript ────────────────────────────────────────────────────────────
1492
  tags$script(HTML("
1493
  var cytoData = null;
1494
  var cytoSettings = {};
@@ -1706,7 +1702,7 @@ ui <- fluidPage(
1706
  ctx.stroke();
1707
  ctx.restore();
1708
 
1709
- // Centromere-style notch at ~0.45 of chromosome height
1710
  if (chrH > 30) {
1711
  var centY = y0 + Math.round(chrH * 0.45);
1712
  ctx.save();
@@ -1980,9 +1976,18 @@ server <- function(input, output, session) {
1980
  res <- analysis_results()
1981
  lm <- res$linkage_map
1982
  df_g <- res$original_data
 
 
1983
  cyto_data_list <- build_cyto_plot_data(lm, df_g, input$cyto_chromosome_select)
 
 
 
 
 
 
 
1984
  msg <- list(
1985
- data = list(chromosomes = lapply(cyto_data_list, function(x) x)),
1986
  settings = list(
1987
  chromWidth = input$cyto_chrom_width,
1988
  chromSpacing = input$cyto_chrom_spacing,
 
528
  }
529
 
530
  # ═══════════════════════════════════════════════════════════════════════════════
531
+ # CYTOGENETIC PLOT DATA BUILDER (FIXED)
532
  # ═══════════════════════════════════════════════════════════════════════════════
533
 
534
  build_cyto_plot_data <- function(linkage_map, df_retained, selected_chromosomes) {
535
  if (is.null(selected_chromosomes) || length(selected_chromosomes) == 0) return(list())
536
+
537
+ # Ensure linkage_map has Position column
538
+ if (is.null(linkage_map$Position)) linkage_map$Position <- NA_real_
539
+
540
+ # Get genotype columns (all columns except Marker, Chromosome, .input_order, Position, Status, Reason, Detail)
541
+ exclude_cols <- c("Marker", "Chromosome", ".input_order", "Position", "Status", "Reason", "Detail")
542
+ geno_cols <- setdiff(colnames(df_retained), exclude_cols)
543
+
544
+ # Sort chromosomes numerically if possible
545
  chr_sorted <- tryCatch(
546
  selected_chromosomes[order(as.numeric(selected_chromosomes))],
547
  warning = function(w) sort(selected_chromosomes),
548
  error = function(e) sort(selected_chromosomes)
549
  )
550
+
 
 
 
 
551
  result <- list()
552
  for (chr in chr_sorted) {
553
+ # Get markers for this chromosome with valid positions
554
  sub_map <- linkage_map[linkage_map$Chromosome == chr & !is.na(linkage_map$Position), ]
555
  if (nrow(sub_map) == 0) next
556
  sub_map <- sub_map[order(sub_map$Position), ]
557
+
558
+ # Get genotype data for these markers
559
  sub_geno <- df_retained[df_retained$Marker %in% sub_map$Marker, ]
560
+
561
+ marker_data <- list()
562
+ for (i in seq_len(nrow(sub_map))) {
563
+ mk <- sub_map$Marker[i]
564
  pos <- sub_map$Position[i]
565
+
566
+ # Get genotype row for this marker
567
+ geno_row <- sub_geno[sub_geno$Marker == mk, geno_cols, drop = FALSE]
568
+
569
  if (nrow(geno_row) == 0 || length(geno_cols) == 0) {
570
+ marker_data[[i]] <- list(
571
+ marker = mk,
572
+ position = round(pos, 3),
573
+ allele_a = 0,
574
+ allele_b = 0,
575
+ allele_ab = 0,
576
+ allele_miss = 1
577
+ )
578
+ next
579
  }
580
+
581
  vals <- unlist(geno_row)
582
  vals <- vals[!is.na(vals)]
583
  n_total <- length(vals)
584
  if (n_total == 0) n_total <- 1
585
+
586
+ marker_data[[i]] <- list(
587
+ marker = mk,
588
+ position = round(pos, 3),
589
+ allele_a = round(sum(vals == "a", na.rm = TRUE) / n_total, 4),
590
+ allele_b = round(sum(vals == "b", na.rm = TRUE) / n_total, 4),
591
+ allele_ab = round(sum(vals == "ab", na.rm = TRUE) / n_total, 4),
592
+ allele_miss = round(sum(!(vals %in% c("a","b","ab")), na.rm = TRUE) / n_total, 4)
593
  )
594
+ }
595
+
596
+ if (length(marker_data) > 0) {
597
+ result[[chr]] <- list(
598
+ chromosome = chr,
599
+ max_pos = round(max(sub_map$Position, na.rm = TRUE), 2),
600
+ n_markers = nrow(sub_map),
601
+ markers = marker_data
602
+ )
603
+ }
604
  }
605
  result
606
  }
607
 
608
  # ═══════════════════════════════════════════════════════════════════════════════
609
+ # HIGH-RESOLUTION GGPLOT LINKAGE MAP
610
  # ═══════════════════════════════════════════════════════════════════════════════
611
 
612
  create_ggplot_linkage_map <- function(linkage_map,
 
805
  }
806
 
807
  # ═════════════════════════════���═════════════════════════════════════════════════
808
+ # RECOMBINATION HEATMAP
809
  # ═══════════════════════════════════════════════════════════════════════════════
810
 
811
  create_recombination_heatmap <- function(rec_data, selected_chr, top_n = 60) {
 
855
  }
856
 
857
  # ═══════════════════════════════════════════════════════════════════════════════
858
+ # MARKER DENSITY PLOT
859
  # ═══════════════════════════════════════════════════════════════════════════════
860
 
861
  create_marker_density_plot <- function(linkage_map, selected_chr, bin_width = 10) {
 
916
 
917
  ui <- fluidPage(
918
  tags$head(
 
919
  tags$style(HTML("
920
  @import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap');
921
 
 
928
  margin: 0; padding-bottom: 60px;
929
  }
930
 
 
931
  .navbar-default {
932
  background: linear-gradient(135deg, #0F172A 0%, #1E3A8A 60%, #1D4ED8 100%) !important;
933
  border: none !important;
 
959
  border-bottom: 3px solid #818CF8;
960
  }
961
 
 
962
  .card {
963
  background: #fff;
964
  border-radius: 12px;
 
975
  }
976
  .card h4 { font-size: 14px; font-weight: 600; color: #3B4FCC; margin: 16px 0 10px; }
977
 
 
978
  .well {
979
  background: #fff;
980
  border: 1px solid #E2E8F0;
 
983
  padding: 18px;
984
  }
985
 
 
986
  .form-control {
987
  border: 1.5px solid #CBD5E1;
988
  border-radius: 8px;
 
997
  .irs--shiny .irs-handle { background: #6366F1; border-color: #4F46E5; }
998
  .irs--shiny .irs-from, .irs--shiny .irs-to, .irs--shiny .irs-single { background: #4F46E5; }
999
 
 
1000
  .btn {
1001
  border-radius: 8px;
1002
  font-family: 'DM Sans', sans-serif;
 
1028
  }
1029
  .btn-block { width: 100%; display: block; }
1030
 
 
1031
  .alert-info {
1032
  background: #EFF6FF; border: 1px solid #BFDBFE;
1033
  color: #1E40AF; border-radius: 10px; font-size: 13px;
 
1041
  color: #065F46; border-radius: 10px; font-size: 13px;
1042
  }
1043
 
 
1044
  .plot-wrapper {
1045
  background: #fff;
1046
  border-radius: 12px;
 
1049
  box-shadow: 0 4px 20px rgba(30,58,138,0.08);
1050
  }
1051
 
 
1052
  #cyto-scroll-wrapper {
1053
  overflow-x: auto; overflow-y: hidden;
1054
  background: #fff;
 
1060
  #cytoCanvas {
1061
  display: block;
1062
  cursor: crosshair;
1063
+ image-rendering: crisp-edges;
1064
  }
1065
  #cyto-tooltip {
1066
  position: fixed;
 
1100
  .legend-item { display: flex; align-items: center; gap: 7px; font-weight: 500; }
1101
  .legend-swatch { width: 18px; height: 18px; border-radius: 4px; border: 1px solid rgba(0,0,0,0.1); }
1102
 
 
1103
  .dataTables_wrapper { font-size: 13px; }
1104
  table.dataTable { border: 1px solid #E2E8F0 !important; border-radius: 8px; }
1105
  table.dataTable thead th {
 
1110
  }
1111
  table.dataTable tbody tr:hover { background: #EEF2FF !important; }
1112
 
 
1113
  pre { font-family: 'JetBrains Mono', monospace; font-size: 12px; background: #F1F5F9; border-radius: 8px; border: 1px solid #E2E8F0; }
1114
 
 
1115
  .footer {
1116
  position: fixed; bottom: 0; width: 100%;
1117
  background: linear-gradient(90deg, #0F172A, #1E3A8A);
 
1121
  z-index: 100;
1122
  }
1123
 
 
1124
  .chi-panel {
1125
  background: #F0FDF4; border: 1px solid #86EFAC;
1126
  border-radius: 8px; padding: 14px; margin-top: 10px;
 
1131
  font-size: 12px; color: #991B1B;
1132
  }
1133
 
 
1134
  .stat-badge {
1135
  display: inline-flex; align-items: center; justify-content: center;
1136
  background: linear-gradient(135deg,#EEF2FF,#DBEAFE);
 
1149
  id = "nav",
1150
  collapsible = TRUE,
1151
 
 
1152
  tabPanel("πŸ“ Upload", icon = icon("upload"),
1153
  sidebarLayout(
1154
  sidebarPanel(width = 4,
 
1164
  hr(),
1165
  div(class = "alert alert-info",
1166
  tags$b("✨ v6.0 Features:"), br(),
1167
+ "β€’ High-resolution ggplot linkage map", br(),
1168
  "β€’ Recombination fraction heatmap", br(),
1169
  "β€’ Marker density distribution plot", br(),
1170
  "β€’ Cytogenetic ideogram with hover tooltips", br(),
1171
+ "β€’ Allele frequency banding per chromosome", br(),
1172
  "β€’ Full Excel export with all analysis sheets"
1173
  )
1174
  )
 
1190
  )
1191
  ),
1192
 
 
1193
  tabPanel("βš™οΈ Parameters", icon = icon("sliders-h"),
1194
  sidebarLayout(
1195
  sidebarPanel(width = 4,
 
1248
  )
1249
  ),
1250
 
 
1251
  tabPanel("πŸ” QC Report", icon = icon("clipboard-check"),
1252
  div(class="card",
1253
  h3("πŸ“‹ Quality Control Report"),
 
1262
  )
1263
  ),
1264
 
 
1265
  tabPanel("πŸ“Š Results", icon = icon("table"),
1266
  div(class="card",
1267
  h3("πŸ“Š Analysis Results"),
 
1297
  )
1298
  ),
1299
 
 
1300
  tabPanel("πŸ—ΊοΈ Map Plot", icon = icon("chart-bar"),
1301
  sidebarLayout(
1302
  sidebarPanel(width = 3,
 
1338
  )
1339
  ),
1340
 
 
1341
  tabPanel("πŸ“‰ Density & RF", icon = icon("chart-area"),
1342
  fluidRow(
1343
  column(12,
 
1383
  )
1384
  ),
1385
 
 
1386
  tabPanel("🧬 Cytogenetic", icon = icon("dna"),
1387
  div(class="card",
1388
  h3("🧬 High-Resolution Cytogenetic Ideogram"),
 
1422
  style="background:rgba(148,163,184,0.4); border:1px dashed #94A3B8;"),
1423
  tags$span("Missing / unknown"))
1424
  ),
 
 
1425
  br(),
1426
  fluidRow(
1427
  column(3, sliderInput("cyto_chrom_width", "Chromosome Width:",
 
1451
  )
1452
  ),
1453
 
 
1454
  tabPanel("❓ Help", icon = icon("question-circle"),
1455
  div(class="card",
1456
  h3("πŸ“– Application Guide β€” v6.0"),
 
1483
  )
1484
  ),
1485
 
 
1486
  div(id = "cyto-tooltip"),
1487
 
 
1488
  tags$script(HTML("
1489
  var cytoData = null;
1490
  var cytoSettings = {};
 
1702
  ctx.stroke();
1703
  ctx.restore();
1704
 
1705
+ // Centromere-style notch
1706
  if (chrH > 30) {
1707
  var centY = y0 + Math.round(chrH * 0.45);
1708
  ctx.save();
 
1976
  res <- analysis_results()
1977
  lm <- res$linkage_map
1978
  df_g <- res$original_data
1979
+
1980
+ # Build cytogenetic plot data
1981
  cyto_data_list <- build_cyto_plot_data(lm, df_g, input$cyto_chromosome_select)
1982
+
1983
+ # Convert list to array for JavaScript
1984
+ chromosomes_array <- list()
1985
+ for (chr_name in names(cyto_data_list)) {
1986
+ chromosomes_array[[length(chromosomes_array) + 1]] <- cyto_data_list[[chr_name]]
1987
+ }
1988
+
1989
  msg <- list(
1990
+ data = list(chromosomes = chromosomes_array),
1991
  settings = list(
1992
  chromWidth = input$cyto_chrom_width,
1993
  chromSpacing = input$cyto_chrom_spacing,