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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Export Data to Excel</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<script src="https://cdn.sheetjs.com/xlsx-0.19.3/package/dist/xlsx.full.min.js"></script>
|
| 9 |
+
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 10 |
+
</head>
|
| 11 |
+
<body class="bg-gray-50 min-h-screen flex items-center justify-center">
|
| 12 |
+
<div class="bg-white rounded-lg shadow-lg p-8 max-w-md w-full">
|
| 13 |
+
<div class="text-center mb-6">
|
| 14 |
+
<i data-feather="download" class="w-12 h-12 text-blue-500 mx-auto"></i>
|
| 15 |
+
<h1 class="text-2xl font-bold text-gray-800 mt-4">Export Data to Excel</h1>
|
| 16 |
+
<p class="text-gray-600 mt-2">Download all chart data as an Excel spreadsheet</p>
|
| 17 |
+
</div>
|
| 18 |
+
|
| 19 |
+
<div class="space-y-4">
|
| 20 |
+
<button id="exportAllBtn" class="w-full bg-blue-500 hover:bg-blue-600 text-white py-3 px-4 rounded-lg flex items-center justify-center">
|
| 21 |
+
<i data-feather="download-cloud" class="mr-2"></i>
|
| 22 |
+
Export All Data
|
| 23 |
+
</button>
|
| 24 |
+
|
| 25 |
+
<div class="border-t border-gray-200 pt-4">
|
| 26 |
+
<h2 class="text-lg font-medium text-gray-800 mb-3">Export Individual Charts</h2>
|
| 27 |
+
<div class="space-y-2">
|
| 28 |
+
<button id="exportDiversityBtn" class="w-full bg-gray-100 hover:bg-gray-200 text-gray-800 py-2 px-4 rounded flex items-center justify-between">
|
| 29 |
+
<span>Diversity Metrics</span>
|
| 30 |
+
<i data-feather="chevron-right" class="text-gray-500"></i>
|
| 31 |
+
</button>
|
| 32 |
+
<button id="exportAdmixtureBtn" class="w-full bg-gray-100 hover:bg-gray-200 text-gray-800 py-2 px-4 rounded flex items-center justify-between">
|
| 33 |
+
<span>Admixture Data</span>
|
| 34 |
+
<i data-feather="chevron-right" class="text-gray-500"></i>
|
| 35 |
+
</button>
|
| 36 |
+
<button id="exportHeteroBtn" class="w-full bg-gray-100 hover:bg-gray-200 text-gray-800 py-2 px-4 rounded flex items-center justify-between">
|
| 37 |
+
<span>Heterozygosity</span>
|
| 38 |
+
<i data-feather="chevron-right" class="text-gray-500"></i>
|
| 39 |
+
</button>
|
| 40 |
+
<button id="exportSnpBtn" class="w-full bg-gray-100 hover:bg-gray-200 text-gray-800 py-2 px-4 rounded flex items-center justify-between">
|
| 41 |
+
<span>SNP Distribution</span>
|
| 42 |
+
<i data-feather="chevron-right" class="text-gray-500"></i>
|
| 43 |
+
</button>
|
| 44 |
+
</div>
|
| 45 |
+
</div>
|
| 46 |
+
</div>
|
| 47 |
+
</div>
|
| 48 |
+
|
| 49 |
+
<script>
|
| 50 |
+
feather.replace();
|
| 51 |
+
|
| 52 |
+
// Chart data (same as in index.html)
|
| 53 |
+
const chartData = {
|
| 54 |
+
diversity: {
|
| 55 |
+
labels: ['rs16985665', 'rs405509', 'rs662799', 'rs7258249', 'rs778796405', 'rs878854023', 'rs886046425', 'rs944580031'],
|
| 56 |
+
values: [1.62, 1.85, 1.43, 1.71, 1.92, 1.38, 1.67, 1.24]
|
| 57 |
+
},
|
| 58 |
+
admixture: {
|
| 59 |
+
labels: ['Ancestry Group 1', 'Ancestry Group 2'],
|
| 60 |
+
values: [72, 28]
|
| 61 |
+
},
|
| 62 |
+
heterozygosity: {
|
| 63 |
+
labels: ['rs16985665', 'rs405509', 'rs662799', 'rs7258249', 'rs778796405'],
|
| 64 |
+
caseValues: [0.34, 0.42, 0.31, 0.38, 0.45],
|
| 65 |
+
controlValues: [0.38, 0.48, 0.35, 0.42, 0.51]
|
| 66 |
+
},
|
| 67 |
+
snpDistribution: {
|
| 68 |
+
labels: ['rs16985665', 'rs405509', 'rs662799', 'rs7258249', 'rs778796405', 'rs878854023', 'rs886046425', 'rs944580031'],
|
| 69 |
+
caseValues: [0.42, 0.38, 0.45, 0.39, 0.51, 0.18, 0.48, 0.05],
|
| 70 |
+
controlValues: [0.38, 0.45, 0.42, 0.44, 0.55, 0.22, 0.51, 0.08]
|
| 71 |
+
}
|
| 72 |
+
};
|
| 73 |
+
|
| 74 |
+
// Function to export data to Excel
|
| 75 |
+
function exportToExcel(data, sheetName, fileName) {
|
| 76 |
+
const ws = XLSX.utils.json_to_sheet(data);
|
| 77 |
+
const wb = XLSX.utils.book_new();
|
| 78 |
+
XLSX.utils.book_append_sheet(wb, ws, sheetName);
|
| 79 |
+
XLSX.writeFile(wb, `${fileName}.xlsx`);
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
// Export all data
|
| 83 |
+
document.getElementById('exportAllBtn').addEventListener('click', function() {
|
| 84 |
+
// Create a workbook with multiple sheets
|
| 85 |
+
const wb = XLSX.utils.book_new();
|
| 86 |
+
|
| 87 |
+
// Diversity data
|
| 88 |
+
const diversityData = chartData.diversity.labels.map((label, i) => ({
|
| 89 |
+
SNP: label,
|
| 90 |
+
'Shannon Index': chartData.diversity.values[i]
|
| 91 |
+
}));
|
| 92 |
+
const ws1 = XLSX.utils.json_to_sheet(diversityData);
|
| 93 |
+
XLSX.utils.book_append_sheet(wb, ws1, "Diversity");
|
| 94 |
+
|
| 95 |
+
// Admixture data
|
| 96 |
+
const admixtureData = chartData.admixture.labels.map((label, i) => ({
|
| 97 |
+
'Ancestry Group': label,
|
| 98 |
+
Percentage: chartData.admixture.values[i]
|
| 99 |
+
}));
|
| 100 |
+
const ws2 = XLSX.utils.json_to_sheet(admixtureData);
|
| 101 |
+
XLSX.utils.book_append_sheet(wb, ws2, "Admixture");
|
| 102 |
+
|
| 103 |
+
// Heterozygosity data
|
| 104 |
+
const heteroData = chartData.heterozygosity.labels.map((label, i) => ({
|
| 105 |
+
SNP: label,
|
| 106 |
+
'Case Heterozygosity': chartData.heterozygosity.caseValues[i],
|
| 107 |
+
'Control Heterozygosity': chartData.heterozygosity.controlValues[i]
|
| 108 |
+
}));
|
| 109 |
+
const ws3 = XLSX.utils.json_to_sheet(heteroData);
|
| 110 |
+
XLSX.utils.book_append_sheet(wb, ws3, "Heterozygosity");
|
| 111 |
+
|
| 112 |
+
// SNP Distribution data
|
| 113 |
+
const snpData = chartData.snpDistribution.labels.map((label, i) => ({
|
| 114 |
+
SNP: label,
|
| 115 |
+
'Case Frequency': chartData.snpDistribution.caseValues[i],
|
| 116 |
+
'Control Frequency': chartData.snpDistribution.controlValues[i]
|
| 117 |
+
}));
|
| 118 |
+
const ws4 = XLSX.utils.json_to_sheet(snpData);
|
| 119 |
+
XLSX.utils.book_append_sheet(wb, ws4, "SNP Distribution");
|
| 120 |
+
|
| 121 |
+
// Export the workbook
|
| 122 |
+
XLSX.writeFile(wb, "Genetic_Data_Export.xlsx");
|
| 123 |
+
});
|
| 124 |
+
|
| 125 |
+
// Individual exports
|
| 126 |
+
document.getElementById('exportDiversityBtn').addEventListener('click', function() {
|
| 127 |
+
const data = chartData.diversity.labels.map((label, i) => ({
|
| 128 |
+
SNP: label,
|
| 129 |
+
'Shannon Index': chartData.diversity.values[i]
|
| 130 |
+
}));
|
| 131 |
+
exportToExcel(data, "Diversity", "Diversity_Metrics");
|
| 132 |
+
});
|
| 133 |
+
|
| 134 |
+
document.getElementById('exportAdmixtureBtn').addEventListener('click', function() {
|
| 135 |
+
const data = chartData.admixture.labels.map((label, i) => ({
|
| 136 |
+
'Ancestry Group': label,
|
| 137 |
+
Percentage: chartData.admixture.values[i]
|
| 138 |
+
}));
|
| 139 |
+
exportToExcel(data, "Admixture", "Admixture_Data");
|
| 140 |
+
});
|
| 141 |
+
|
| 142 |
+
document.getElementById('exportHeteroBtn').addEventListener('click', function() {
|
| 143 |
+
const data = chartData.heterozygosity.labels.map((label, i) => ({
|
| 144 |
+
SNP: label,
|
| 145 |
+
'Case Heterozygosity': chartData.heterozygosity.caseValues[i],
|
| 146 |
+
'Control Heterozygosity': chartData.heterozygosity.controlValues[i]
|
| 147 |
+
}));
|
| 148 |
+
exportToExcel(data, "Heterozygosity", "Heterozygosity_Data");
|
| 149 |
+
});
|
| 150 |
+
|
| 151 |
+
document.getElementById('exportSnpBtn').addEventListener('click', function() {
|
| 152 |
+
const data = chartData.snpDistribution.labels.map((label, i) => ({
|
| 153 |
+
SNP: label,
|
| 154 |
+
'Case Frequency': chartData.snpDistribution.caseValues[i],
|
| 155 |
+
'Control Frequency': chartData.snpDistribution.controlValues[i]
|
| 156 |
+
}));
|
| 157 |
+
exportToExcel(data, "SNP Distribution", "SNP_Distribution");
|
| 158 |
+
});
|
| 159 |
+
</script>
|
| 160 |
+
</body>
|
| 161 |
+
</html>
|
prompts.txt
CHANGED
|
@@ -73,4 +73,5 @@ C39 Control 2 2 2 4 1 1 1 2 3 3 0 0 2 2 0 0
|
|
| 73 |
C40 Control 1 1 2 4 1 1 1 2 3 3 0 0 2 2 0 0
|
| 74 |
Please revise this to reflect the Shannon Index, heterogeneity, and admixture
|
| 75 |
Please revise this to reflect the Shannon Index, heterogeneity, and admixture
|
| 76 |
-
The SNP distribution chart is missing data
|
|
|
|
|
|
| 73 |
C40 Control 1 1 2 4 1 1 1 2 3 3 0 0 2 2 0 0
|
| 74 |
Please revise this to reflect the Shannon Index, heterogeneity, and admixture
|
| 75 |
Please revise this to reflect the Shannon Index, heterogeneity, and admixture
|
| 76 |
+
The SNP distribution chart is missing data
|
| 77 |
+
Export these data charts into excel
|