Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,6 +18,7 @@ FIXES APPLIED:
|
|
| 18 |
β
FarmCPU: Fixed iterative conditioning
|
| 19 |
β
Kinship matrix: Now positive definite
|
| 20 |
β
ALL plots: White background, black/dark text for publication quality
|
|
|
|
| 21 |
"""
|
| 22 |
|
| 23 |
import gradio as gr
|
|
@@ -39,6 +40,30 @@ from sklearn.decomposition import PCA
|
|
| 39 |
from sklearn.cluster import KMeans
|
| 40 |
warnings.filterwarnings('ignore')
|
| 41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
OUTPUT_DIR = Path("/tmp/gwas_outputs")
|
| 43 |
OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
|
| 44 |
|
|
@@ -1422,7 +1447,7 @@ def run_analysis(input_file, miss_sample, miss_marker, maf_thresh,
|
|
| 1422 |
fp = os.path.join(root, f)
|
| 1423 |
zf.write(fp, os.path.relpath(fp, str(rdir)))
|
| 1424 |
|
| 1425 |
-
# Create summary markdown
|
| 1426 |
summary = f"""
|
| 1427 |
## β
GWAS Analysis Complete β v11.0
|
| 1428 |
|
|
@@ -1452,8 +1477,15 @@ def run_analysis(input_file, miss_sample, miss_marker, maf_thresh,
|
|
| 1452 |
- `plots/` β All figures (Manhattan, QQ, LD, PCA, etc.)
|
| 1453 |
|
| 1454 |
### π Top Markers
|
| 1455 |
-
|
| 1456 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1457 |
---
|
| 1458 |
*MTA GWAS v11.0 β Fixed LD decay (Hill-Weir model) | All models functional | White background*
|
| 1459 |
"""
|
|
|
|
| 18 |
β
FarmCPU: Fixed iterative conditioning
|
| 19 |
β
Kinship matrix: Now positive definite
|
| 20 |
β
ALL plots: White background, black/dark text for publication quality
|
| 21 |
+
β
Fixed tabulate dependency issue
|
| 22 |
"""
|
| 23 |
|
| 24 |
import gradio as gr
|
|
|
|
| 40 |
from sklearn.cluster import KMeans
|
| 41 |
warnings.filterwarnings('ignore')
|
| 42 |
|
| 43 |
+
# Try to import tabulate, provide fallback if not available
|
| 44 |
+
try:
|
| 45 |
+
from tabulate import tabulate
|
| 46 |
+
TABULATE_AVAILABLE = True
|
| 47 |
+
except ImportError:
|
| 48 |
+
TABULATE_AVAILABLE = False
|
| 49 |
+
# Define a simple tabulate function as fallback
|
| 50 |
+
def tabulate(data, headers="keys", tablefmt="pipe", **kwargs):
|
| 51 |
+
"""Simple fallback tabulate function."""
|
| 52 |
+
if headers == "keys":
|
| 53 |
+
headers = list(data.columns)
|
| 54 |
+
|
| 55 |
+
# Create markdown table
|
| 56 |
+
lines = []
|
| 57 |
+
# Header row
|
| 58 |
+
lines.append("| " + " | ".join(str(h) for h in headers) + " |")
|
| 59 |
+
# Separator row
|
| 60 |
+
lines.append("|" + "|".join([" --- " for _ in headers]) + "|")
|
| 61 |
+
# Data rows
|
| 62 |
+
for _, row in data.iterrows():
|
| 63 |
+
lines.append("| " + " | ".join(str(v) for v in row.values) + " |")
|
| 64 |
+
|
| 65 |
+
return "\n".join(lines)
|
| 66 |
+
|
| 67 |
OUTPUT_DIR = Path("/tmp/gwas_outputs")
|
| 68 |
OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
|
| 69 |
|
|
|
|
| 1447 |
fp = os.path.join(root, f)
|
| 1448 |
zf.write(fp, os.path.relpath(fp, str(rdir)))
|
| 1449 |
|
| 1450 |
+
# Create summary markdown with fallback for tabulate
|
| 1451 |
summary = f"""
|
| 1452 |
## β
GWAS Analysis Complete β v11.0
|
| 1453 |
|
|
|
|
| 1477 |
- `plots/` β All figures (Manhattan, QQ, LD, PCA, etc.)
|
| 1478 |
|
| 1479 |
### π Top Markers
|
| 1480 |
+
"""
|
| 1481 |
+
# Create top markers table manually (without tabulate)
|
| 1482 |
+
top_df = df[['Rank', 'Marker', 'Chromosome', 'Position_bp'] + [f'{m}_P' for m in model_pvals.keys()]].head(10)
|
| 1483 |
+
summary += "| " + " | ".join(top_df.columns) + " |\n"
|
| 1484 |
+
summary += "|" + "|".join([" --- " for _ in top_df.columns]) + "|\n"
|
| 1485 |
+
for _, row in top_df.iterrows():
|
| 1486 |
+
summary += "| " + " | ".join(str(v) for v in row.values) + " |\n"
|
| 1487 |
+
|
| 1488 |
+
summary += """
|
| 1489 |
---
|
| 1490 |
*MTA GWAS v11.0 β Fixed LD decay (Hill-Weir model) | All models functional | White background*
|
| 1491 |
"""
|