taxontabletools2 2.3.2__tar.gz → 2.3.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {taxontabletools2-2.3.2/taxontabletools2.egg-info → taxontabletools2-2.3.4}/PKG-INFO +4 -2
- {taxontabletools2-2.3.2 → taxontabletools2-2.3.4}/setup.py +4 -2
- {taxontabletools2-2.3.2 → taxontabletools2-2.3.4}/taxontabletools2/taxontabletools_2.0.py +196 -28
- taxontabletools2-2.3.4/taxontabletools2/user_preferences.xlsx +0 -0
- {taxontabletools2-2.3.2 → taxontabletools2-2.3.4/taxontabletools2.egg-info}/PKG-INFO +4 -2
- {taxontabletools2-2.3.2 → taxontabletools2-2.3.4}/taxontabletools2.egg-info/requires.txt +3 -1
- taxontabletools2-2.3.2/taxontabletools2/user_preferences.xlsx +0 -0
- {taxontabletools2-2.3.2 → taxontabletools2-2.3.4}/LICENSE +0 -0
- {taxontabletools2-2.3.2 → taxontabletools2-2.3.4}/MANIFEST.in +0 -0
- {taxontabletools2-2.3.2 → taxontabletools2-2.3.4}/README.md +0 -0
- {taxontabletools2-2.3.2 → taxontabletools2-2.3.4}/setup.cfg +0 -0
- {taxontabletools2-2.3.2 → taxontabletools2-2.3.4}/taxontabletools2/Rscripts/EFI.R +0 -0
- {taxontabletools2-2.3.2 → taxontabletools2-2.3.4}/taxontabletools2/Rscripts/diathor.R +0 -0
- {taxontabletools2-2.3.2 → taxontabletools2-2.3.4}/taxontabletools2/Rscripts/internal/.DS_Store +0 -0
- {taxontabletools2-2.3.2 → taxontabletools2-2.3.4}/taxontabletools2/Rscripts/internal/efiminus.R +0 -0
- {taxontabletools2-2.3.2 → taxontabletools2-2.3.4}/taxontabletools2/Rscripts/internal/internal.zip +0 -0
- {taxontabletools2-2.3.2 → taxontabletools2-2.3.4}/taxontabletools2/WFD_conversion/.DS_Store +0 -0
- {taxontabletools2-2.3.2 → taxontabletools2-2.3.4}/taxontabletools2/WFD_conversion/efi_ecoregions.png +0 -0
- {taxontabletools2-2.3.2 → taxontabletools2-2.3.4}/taxontabletools2/WFD_conversion/efi_table.xlsx +0 -0
- {taxontabletools2-2.3.2 → taxontabletools2-2.3.4}/taxontabletools2/__init__.py +0 -0
- {taxontabletools2-2.3.2 → taxontabletools2-2.3.4}/taxontabletools2/__main__.py +0 -0
- {taxontabletools2-2.3.2 → taxontabletools2-2.3.4}/taxontabletools2/read_table_example.xlsx +0 -0
- {taxontabletools2-2.3.2 → taxontabletools2-2.3.4}/taxontabletools2/taxonomy_table_example.xlsx +0 -0
- {taxontabletools2-2.3.2 → taxontabletools2-2.3.4}/taxontabletools2.egg-info/SOURCES.txt +0 -0
- {taxontabletools2-2.3.2 → taxontabletools2-2.3.4}/taxontabletools2.egg-info/dependency_links.txt +0 -0
- {taxontabletools2-2.3.2 → taxontabletools2-2.3.4}/taxontabletools2.egg-info/entry_points.txt +0 -0
- {taxontabletools2-2.3.2 → taxontabletools2-2.3.4}/taxontabletools2.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: taxontabletools2
|
|
3
|
-
Version: 2.3.
|
|
3
|
+
Version: 2.3.4
|
|
4
4
|
Summary: Taxontabletools2 - A comprehensive, platform-independent graphical user interface software to explore and visualise DNA metabarcoding data
|
|
5
5
|
Home-page: https://pypi.org/project/taxontabletools2
|
|
6
6
|
Author: Till-Hendrik Macher
|
|
@@ -12,9 +12,11 @@ Classifier: Operating System :: OS Independent
|
|
|
12
12
|
Requires-Python: >=3.10
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
License-File: LICENSE
|
|
15
|
-
Requires-Dist: streamlit
|
|
15
|
+
Requires-Dist: streamlit>=1.54.0
|
|
16
16
|
Requires-Dist: stqdm
|
|
17
17
|
Requires-Dist: pygbif
|
|
18
|
+
Requires-Dist: tables
|
|
19
|
+
Requires-Dist: streamlit-sortables
|
|
18
20
|
Requires-Dist: geopandas
|
|
19
21
|
Requires-Dist: scikit-learn
|
|
20
22
|
Requires-Dist: xlsxwriter
|
|
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
|
|
|
5
5
|
|
|
6
6
|
setuptools.setup(
|
|
7
7
|
name="taxontabletools2",
|
|
8
|
-
version="2.3.
|
|
8
|
+
version="2.3.4",
|
|
9
9
|
author="Till-Hendrik Macher",
|
|
10
10
|
author_email="macher@uni-trier.de",
|
|
11
11
|
description="Taxontabletools2 - A comprehensive, platform-independent graphical user interface software to explore and visualise DNA metabarcoding data",
|
|
@@ -15,9 +15,11 @@ setuptools.setup(
|
|
|
15
15
|
packages=setuptools.find_packages(),
|
|
16
16
|
license = 'MIT',
|
|
17
17
|
install_requires=[
|
|
18
|
-
"streamlit",
|
|
18
|
+
"streamlit>=1.54.0",
|
|
19
19
|
"stqdm",
|
|
20
20
|
"pygbif",
|
|
21
|
+
"tables",
|
|
22
|
+
"streamlit-sortables",
|
|
21
23
|
"geopandas",
|
|
22
24
|
"scikit-learn",
|
|
23
25
|
"xlsxwriter",
|
|
@@ -48,6 +48,14 @@ from shapely.geometry.polygon import orient
|
|
|
48
48
|
from itertools import product
|
|
49
49
|
import shapely.wkt as wkt
|
|
50
50
|
from pygbif import maps
|
|
51
|
+
import warnings
|
|
52
|
+
import tables
|
|
53
|
+
from streamlit_sortables import sort_items
|
|
54
|
+
|
|
55
|
+
########################################################################################################################
|
|
56
|
+
## supress table warning (for now)
|
|
57
|
+
warnings.filterwarnings("ignore", category=tables.NaturalNameWarning)
|
|
58
|
+
warnings.filterwarnings("ignore", category=pd.errors.PerformanceWarning)
|
|
51
59
|
|
|
52
60
|
########################################################################################################################
|
|
53
61
|
## session state cheat sheet
|
|
@@ -92,6 +100,21 @@ if 'test' == 'pass':
|
|
|
92
100
|
df_samples = df_metadata_table['Samples'].values.tolist()
|
|
93
101
|
selected_metadata = 'Season'
|
|
94
102
|
|
|
103
|
+
excel_file = Path('/Users/tillmacher/Desktop/_dev/h5_test/Cave_main_taxon_table.xlsx')
|
|
104
|
+
large_df = pd.read_excel(excel_file)
|
|
105
|
+
h5_file = Path('/Users/tillmacher/Desktop/_dev/h5_test/Cave_main_taxon_table.h5')
|
|
106
|
+
large_df.to_hdf(h5_file, key='Taxon Table')
|
|
107
|
+
|
|
108
|
+
t0 = time.perf_counter()
|
|
109
|
+
df = pd.read_hdf(h5_file, key='Taxon Table')
|
|
110
|
+
t1 = time.perf_counter()
|
|
111
|
+
print(t1 - t0)
|
|
112
|
+
|
|
113
|
+
t0 = time.perf_counter()
|
|
114
|
+
df = pd.read_excel(excel_file, sheet_name='Taxon Table')
|
|
115
|
+
t1 = time.perf_counter()
|
|
116
|
+
print(t1 - t0)
|
|
117
|
+
|
|
95
118
|
def default_data_handling(): # just for copying
|
|
96
119
|
# Handle Metadata
|
|
97
120
|
if fig_level != 'Samples':
|
|
@@ -228,12 +251,18 @@ def open_file(path: Path):
|
|
|
228
251
|
else:
|
|
229
252
|
subprocess.run(["xdg-open", path])
|
|
230
253
|
|
|
231
|
-
def export_taxon_table(table_display_name, df_taxon_table, df_metadata_table, suffix):
|
|
254
|
+
def export_taxon_table(table_display_name, df_taxon_table, df_metadata_table, suffix, format='.xlsx'):
|
|
232
255
|
|
|
233
256
|
## collect remaining samples and filter metadata_df
|
|
234
257
|
seq_loc = df_taxon_table.columns.tolist().index('Seq')
|
|
235
258
|
samples = df_taxon_table.columns.tolist()[seq_loc+1::]
|
|
236
259
|
|
|
260
|
+
# Fix mixed cols
|
|
261
|
+
mixed_cols = [col for col in df_taxon_table.columns if df_taxon_table[col].apply(type).nunique() > 1]
|
|
262
|
+
df_taxon_table[mixed_cols] = df_taxon_table[mixed_cols].astype(str)
|
|
263
|
+
mixed_cols = [col for col in df_metadata_table.columns if df_metadata_table[col].apply(type).nunique() > 1]
|
|
264
|
+
df_metadata_table[mixed_cols] = df_metadata_table[mixed_cols].astype(str)
|
|
265
|
+
|
|
237
266
|
## Calculate the number of empty OTUs
|
|
238
267
|
empty_otus_count = (~(df_taxon_table[samples] != 0).any(axis=1)).sum()
|
|
239
268
|
|
|
@@ -242,21 +271,26 @@ def export_taxon_table(table_display_name, df_taxon_table, df_metadata_table, su
|
|
|
242
271
|
df_taxon_table = df_taxon_table[mask]
|
|
243
272
|
|
|
244
273
|
if empty_otus_count != 0:
|
|
245
|
-
st.warning(f'Warning: Removed {empty_otus_count}
|
|
274
|
+
st.warning(f'Warning: Removed {empty_otus_count} {st.session_state["TTT_hash"]} where all samples were empty (zero reads).')
|
|
246
275
|
|
|
247
276
|
## create a new file name
|
|
248
277
|
if suffix == '':
|
|
249
|
-
output_xlsx = table_display_name
|
|
278
|
+
output_xlsx = table_display_name.parent / Path(f'{Path(table_display_name).stem}.xlsx')
|
|
250
279
|
else:
|
|
251
|
-
output_xlsx = Path(
|
|
280
|
+
output_xlsx = table_display_name.parent / Path(f'{Path(table_display_name).stem}_{suffix}.xlsx')
|
|
252
281
|
|
|
253
282
|
## sort taxon table
|
|
254
283
|
df_taxon_table = df_taxon_table.sort_values(by=['Phylum', 'Class', 'Order', 'Family', 'Genus', 'Species', 'Similarity'])
|
|
255
284
|
|
|
256
285
|
## export the dataframe
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
286
|
+
if st.session_state['TTT_tableformat'] == '.h5':
|
|
287
|
+
output_h5 = str(output_xlsx.with_suffix('.h5'))
|
|
288
|
+
df_taxon_table.to_hdf(output_h5, key='Taxon Table')
|
|
289
|
+
df_metadata_table.to_hdf(output_h5, key='Metadata Table')
|
|
290
|
+
else:
|
|
291
|
+
with pd.ExcelWriter(output_xlsx) as writer:
|
|
292
|
+
df_taxon_table.to_excel(writer, sheet_name='Taxon Table', index=False)
|
|
293
|
+
df_metadata_table.to_excel(writer, sheet_name='Metadata Table', index=False)
|
|
260
294
|
|
|
261
295
|
def export_plot(folder_name, suffix, fig, lib):
|
|
262
296
|
|
|
@@ -920,7 +954,8 @@ def replicate_merging():
|
|
|
920
954
|
table_display_name,
|
|
921
955
|
df_taxon_table,
|
|
922
956
|
df_metadata_table,
|
|
923
|
-
"merged"
|
|
957
|
+
"merged",
|
|
958
|
+
st.session_state['TTT_tableformat']
|
|
924
959
|
)
|
|
925
960
|
|
|
926
961
|
st.success(
|
|
@@ -972,7 +1007,7 @@ def NC_subtraction():
|
|
|
972
1007
|
table_display_name,
|
|
973
1008
|
df_taxon_table,
|
|
974
1009
|
df_metadata_table,
|
|
975
|
-
suffix
|
|
1010
|
+
suffix, st.session_state['TTT_tableformat']
|
|
976
1011
|
)
|
|
977
1012
|
|
|
978
1013
|
st.success(f'Negative controls were subtracted and a new table was saved to "{str(table_display_name.name).replace(".xlsx", "_NCsub.xlsx")}"')
|
|
@@ -1008,7 +1043,7 @@ def read_based_filter():
|
|
|
1008
1043
|
table_display_name,
|
|
1009
1044
|
df_taxon_table,
|
|
1010
1045
|
st.session_state['df_metadata_table'],
|
|
1011
|
-
suffix
|
|
1046
|
+
suffix, st.session_state['TTT_tableformat']
|
|
1012
1047
|
)
|
|
1013
1048
|
|
|
1014
1049
|
st.success(f'Table was filtered according to read thresholds and a new table was saved to "{str(table_display_name.name).replace(".xlsx", "_readfilter.xlsx")}"')
|
|
@@ -1047,7 +1082,7 @@ def read_based_normalisation():
|
|
|
1047
1082
|
table_display_name,
|
|
1048
1083
|
df,
|
|
1049
1084
|
df_metadata_table,
|
|
1050
|
-
suffix
|
|
1085
|
+
suffix, st.session_state['TTT_tableformat']
|
|
1051
1086
|
)
|
|
1052
1087
|
|
|
1053
1088
|
st.success(f"Table was normalized (subsample size = {sub_sample_size}) and saved to '{str(table_display_name.name).replace('.xlsx', '_norm.xlsx')}'")
|
|
@@ -1078,7 +1113,7 @@ def taxonomic_filter():
|
|
|
1078
1113
|
table_display_name,
|
|
1079
1114
|
df_filtered,
|
|
1080
1115
|
st.session_state['df_metadata_table'],
|
|
1081
|
-
taxon_filter_suffix
|
|
1116
|
+
taxon_filter_suffix, st.session_state['TTT_tableformat']
|
|
1082
1117
|
)
|
|
1083
1118
|
|
|
1084
1119
|
st.success(f'Table was filtered according to the selected taxa and a new table was saved to "{str(table_display_name.name).replace(".xlsx", f"_{taxon_filter_suffix}.xlsx")}"')
|
|
@@ -1118,11 +1153,35 @@ def sample_filter():
|
|
|
1118
1153
|
table_display_name,
|
|
1119
1154
|
df_filtered,
|
|
1120
1155
|
df_metadata_table,
|
|
1121
|
-
sample_filter_suffix
|
|
1156
|
+
sample_filter_suffix, st.session_state['TTT_tableformat']
|
|
1122
1157
|
)
|
|
1123
1158
|
|
|
1124
1159
|
st.success(f'Table was filtered according to the selected samples and a new table was saved to "{str(table_display_name.name).replace(".xlsx", f"_{sample_filter_suffix}.xlsx")}"')
|
|
1125
1160
|
|
|
1161
|
+
def empty_sample_remove():
|
|
1162
|
+
table_display_name = st.session_state['table_display_name']
|
|
1163
|
+
df_taxon_table = st.session_state['df_taxon_table'].copy()
|
|
1164
|
+
df_metadata_table = st.session_state['df_metadata_table'].copy()
|
|
1165
|
+
df_samples = st.session_state['df_samples']
|
|
1166
|
+
lc_threshold = st.session_state['lc_threshold']
|
|
1167
|
+
|
|
1168
|
+
remove_samples = []
|
|
1169
|
+
for sample in df_samples:
|
|
1170
|
+
reads_total = df_taxon_table[sample].sum()
|
|
1171
|
+
if reads_total <= lc_threshold:
|
|
1172
|
+
remove_samples.append(sample)
|
|
1173
|
+
|
|
1174
|
+
if remove_samples == []:
|
|
1175
|
+
st.info('No Samples to Remove!')
|
|
1176
|
+
return
|
|
1177
|
+
else:
|
|
1178
|
+
out_df1 = df_taxon_table.copy()
|
|
1179
|
+
out_df1 = out_df1.drop(columns=remove_samples)
|
|
1180
|
+
out_df2 = df_metadata_table.copy()
|
|
1181
|
+
out_df2 = out_df2[~out_df2['Samples'].isin(remove_samples)]
|
|
1182
|
+
export_taxon_table(table_display_name, out_df1, out_df2, f'min_{lc_threshold}', st.session_state['TTT_tableformat'])
|
|
1183
|
+
st.success(f'Removed {len(remove_samples)} sample(s)!')
|
|
1184
|
+
|
|
1126
1185
|
def trait_filter():
|
|
1127
1186
|
table_display_name = st.session_state['table_display_name']
|
|
1128
1187
|
df_taxon_table = st.session_state['df_taxon_table'].copy()
|
|
@@ -1158,7 +1217,7 @@ def trait_filter():
|
|
|
1158
1217
|
table_display_name,
|
|
1159
1218
|
df_filtered,
|
|
1160
1219
|
st.session_state['df_metadata_table'],
|
|
1161
|
-
trait_filter_suffix
|
|
1220
|
+
trait_filter_suffix, st.session_state['TTT_tableformat']
|
|
1162
1221
|
)
|
|
1163
1222
|
|
|
1164
1223
|
st.success(f'Table was filtered according to the selected traits and a new table was saved to "{str(table_display_name.name).replace(".xlsx", f"_{trait_filter_suffix}.xlsx")}"')
|
|
@@ -1327,7 +1386,7 @@ def merge_taxon_tables():
|
|
|
1327
1386
|
export_metadata_table_df['ESV merge'] = ['Original'] * len(df1_metadata_table) + ['Added'] * len(df2_metadata_table)
|
|
1328
1387
|
|
|
1329
1388
|
## export df
|
|
1330
|
-
export_taxon_table(table_display_name, merged_taxon_table_df, export_metadata_table_df, table_merge_suffix)
|
|
1389
|
+
export_taxon_table(table_display_name, merged_taxon_table_df, export_metadata_table_df, table_merge_suffix, st.session_state['TTT_tableformat'])
|
|
1331
1390
|
|
|
1332
1391
|
st.success(f'Tables were successfully merged!')
|
|
1333
1392
|
|
|
@@ -1423,7 +1482,7 @@ def add_traits_from_file():
|
|
|
1423
1482
|
table_display_name,
|
|
1424
1483
|
df_merged,
|
|
1425
1484
|
st.session_state['df_metadata_table'],
|
|
1426
|
-
''
|
|
1485
|
+
'', st.session_state['TTT_tableformat']
|
|
1427
1486
|
)
|
|
1428
1487
|
st.session_state['df_taxon_table'] = df_merged.copy()
|
|
1429
1488
|
st.success(f'Traits were added and the original table was updated!')
|
|
@@ -1443,7 +1502,7 @@ def sort_samples():
|
|
|
1443
1502
|
table_display_name,
|
|
1444
1503
|
df_sorted,
|
|
1445
1504
|
st.session_state['df_metadata_table'],
|
|
1446
|
-
''
|
|
1505
|
+
'', st.session_state['TTT_tableformat']
|
|
1447
1506
|
)
|
|
1448
1507
|
st.session_state['df_taxon_table'] = df_sorted.copy()
|
|
1449
1508
|
st.success(f'Samples were sorted and the original table was updated!')
|
|
@@ -1464,7 +1523,7 @@ def sample_rename():
|
|
|
1464
1523
|
table_display_name,
|
|
1465
1524
|
df_taxon_table,
|
|
1466
1525
|
df_metadata_table,
|
|
1467
|
-
''
|
|
1526
|
+
'', st.session_state['TTT_tableformat']
|
|
1468
1527
|
)
|
|
1469
1528
|
st.session_state['df_taxon_table'] = df_taxon_table.copy()
|
|
1470
1529
|
st.session_state['df_metadata_table'] = df_metadata_table.copy()
|
|
@@ -2320,6 +2379,14 @@ def pycircos_plot():
|
|
|
2320
2379
|
# Export
|
|
2321
2380
|
export_plot("Alpha_diversity", f"{name}_circos_{fig_taxon0}_{fig_taxon1}_{fig_taxon2}", fig, "matplot")
|
|
2322
2381
|
|
|
2382
|
+
# Export to multiple sheets
|
|
2383
|
+
active_project_path = st.session_state['active_project_path']
|
|
2384
|
+
export_file = active_project_path / "Alpha_diversity" / f"{name}_circos_{fig_taxon0}_{fig_taxon1}_{fig_taxon2}.xlsx"
|
|
2385
|
+
with pd.ExcelWriter(export_file, engine="xlsxwriter") as writer:
|
|
2386
|
+
for key, values in res.items():
|
|
2387
|
+
df = pd.DataFrame(values)
|
|
2388
|
+
df.to_excel(writer, sheet_name=key, index=False)
|
|
2389
|
+
|
|
2323
2390
|
########################################################################################################################
|
|
2324
2391
|
# Beta Diversity
|
|
2325
2392
|
|
|
@@ -2874,7 +2941,6 @@ def haplotype_distribution():
|
|
|
2874
2941
|
res_df = pd.DataFrame(output_lst, columns=['Taxon'] + df_samples)
|
|
2875
2942
|
export_table("Haplotypes", f'{name}_{haplotype_level}_{haplotype_mode}', res_df, "xlsx")
|
|
2876
2943
|
|
|
2877
|
-
|
|
2878
2944
|
########################################################################################################################
|
|
2879
2945
|
# Time Series
|
|
2880
2946
|
def time_series_richness():
|
|
@@ -3124,7 +3190,7 @@ def gbif_accession():
|
|
|
3124
3190
|
df_taxon_table.insert(loc=similarity_loc, column='GBIF', value=OTU_gbif_link)
|
|
3125
3191
|
|
|
3126
3192
|
## export table
|
|
3127
|
-
export_taxon_table(table_display_name, df_taxon_table, df_metadata_table, '')
|
|
3193
|
+
export_taxon_table(table_display_name, df_taxon_table, df_metadata_table, '', st.session_state['TTT_tableformat'])
|
|
3128
3194
|
st.session_state['df_taxon_table'] = df_taxon_table.copy()
|
|
3129
3195
|
st.success('GBIF Data was implemented!')
|
|
3130
3196
|
|
|
@@ -3881,7 +3947,7 @@ def calculate_efi_index():
|
|
|
3881
3947
|
df_metadata_table[col] = values
|
|
3882
3948
|
else:
|
|
3883
3949
|
df_metadata_table[col] = ''
|
|
3884
|
-
export_taxon_table(table_display_name, df_taxon_table, df_metadata_table, '')
|
|
3950
|
+
export_taxon_table(table_display_name, df_taxon_table, df_metadata_table, '', st.session_state['TTT_tableformat'])
|
|
3885
3951
|
st.info('You table was updated - please fill out and reload you Taxon Table.')
|
|
3886
3952
|
open_file(table_display_name)
|
|
3887
3953
|
return
|
|
@@ -4053,6 +4119,7 @@ TTT_input_path_to_projects = ""
|
|
|
4053
4119
|
if user_preferences_xlsx.exists():
|
|
4054
4120
|
user_data_df = pd.read_excel(user_preferences_xlsx).fillna('')
|
|
4055
4121
|
TTT_input_path_to_projects = user_data_df[user_data_df['Variable'] == 'TTT_input_path_to_projects']['Value'].values.tolist()[0]
|
|
4122
|
+
TTT_tableformat = user_data_df[user_data_df['Variable'] == 'TTT_tableformat']['Value'].values.tolist()[0]
|
|
4056
4123
|
TTT_height = user_data_df[user_data_df['Variable'] == 'TTT_height']['Value'].values.tolist()[0]
|
|
4057
4124
|
TTT_width = user_data_df[user_data_df['Variable'] == 'TTT_width']['Value'].values.tolist()[0]
|
|
4058
4125
|
TTT_showlegend = user_data_df[user_data_df['Variable'] == 'TTT_showlegend']['Value'].values.tolist()[0]
|
|
@@ -4132,8 +4199,10 @@ with st.sidebar:
|
|
|
4132
4199
|
# Select Table
|
|
4133
4200
|
st.write(""" ## Taxon Tables """)
|
|
4134
4201
|
|
|
4135
|
-
|
|
4136
|
-
|
|
4202
|
+
# Collect available Files
|
|
4203
|
+
taxon_tables_path = active_project_path / 'TaXon_tables'
|
|
4204
|
+
# collect all .xlsx and .h5 files, skip temp files starting with ~ or ending with .tmp
|
|
4205
|
+
available_taxontables_list = [str(f) for f in taxon_tables_path.glob("*") if f.suffix in (".xlsx", ".h5") and not f.name.startswith("~") and not f.name.endswith(".tmp")]
|
|
4137
4206
|
|
|
4138
4207
|
if available_taxontables_list == []:
|
|
4139
4208
|
st.info('Please first create a Taxon Table!')
|
|
@@ -4141,7 +4210,9 @@ with st.sidebar:
|
|
|
4141
4210
|
else:
|
|
4142
4211
|
|
|
4143
4212
|
if st.button('🔄 Refresh Available Tables', width='stretch'):
|
|
4144
|
-
available_taxontables_list =
|
|
4213
|
+
available_taxontables_list = [str(f) for f in taxon_tables_path.glob("*") if
|
|
4214
|
+
f.suffix in (".xlsx", ".h5") and not f.name.startswith(
|
|
4215
|
+
"~") and not f.name.endswith(".tmp")]
|
|
4145
4216
|
available_taxontables_dict = {Path(i).name:Path(i) for i in available_taxontables_list}
|
|
4146
4217
|
st.selectbox(label='Select a TaXon table:', options=sorted(available_taxontables_dict.keys()), key='selected_table_xlsx', index=0)
|
|
4147
4218
|
|
|
@@ -4153,8 +4224,14 @@ with st.sidebar:
|
|
|
4153
4224
|
if st.button('📥 Load Table', type='primary', width='stretch'):
|
|
4154
4225
|
# Update table name for display
|
|
4155
4226
|
st.session_state['table_display_name'] = Path(active_taxontable_file)
|
|
4227
|
+
|
|
4156
4228
|
# Taxon Table -> df_taxon_table
|
|
4157
|
-
|
|
4229
|
+
if st.session_state['table_display_name'].suffix == '.xlsx':
|
|
4230
|
+
df_taxon_table = pd.read_excel(active_taxontable_file, sheet_name='Taxon Table').fillna('')
|
|
4231
|
+
else:
|
|
4232
|
+
df_taxon_table = pd.read_hdf(active_taxontable_file, key='Taxon Table').fillna('')
|
|
4233
|
+
|
|
4234
|
+
# Taxon Table cols
|
|
4158
4235
|
hash_loc = df_taxon_table.columns.tolist().index('Hash')
|
|
4159
4236
|
species_loc = df_taxon_table.columns.tolist().index('Species')
|
|
4160
4237
|
taxa_cols = df_taxon_table.columns.tolist()[hash_loc+1:species_loc+1]
|
|
@@ -4164,8 +4241,13 @@ with st.sidebar:
|
|
|
4164
4241
|
if 'Taxon' not in df_taxon_table.columns.tolist():
|
|
4165
4242
|
df_taxon_table.insert(similarity_loc, "Taxon", taxon_string)
|
|
4166
4243
|
st.session_state['df_taxon_table'] = df_taxon_table
|
|
4244
|
+
|
|
4167
4245
|
# Metadata Table -> df_metadata_table
|
|
4168
|
-
st.session_state['
|
|
4246
|
+
if st.session_state['table_display_name'].suffix == '.xlsx':
|
|
4247
|
+
st.session_state['df_metadata_table'] = pd.read_excel(active_taxontable_file, sheet_name='Metadata Table').fillna('')
|
|
4248
|
+
else:
|
|
4249
|
+
st.session_state['df_metadata_table'] = pd.read_hdf(active_taxontable_file, key='Metadata Table').fillna('')
|
|
4250
|
+
|
|
4169
4251
|
# Samples -> df_samples
|
|
4170
4252
|
seq_loc = st.session_state['df_taxon_table'].columns.tolist().index('Seq')
|
|
4171
4253
|
taxontable_samples = st.session_state['df_taxon_table'].columns.tolist()[seq_loc+1:]
|
|
@@ -4184,6 +4266,10 @@ with st.sidebar:
|
|
|
4184
4266
|
del st.session_state["df_taxon_table"]
|
|
4185
4267
|
del st.session_state["table_display_name"]
|
|
4186
4268
|
|
|
4269
|
+
# Delete editor tables
|
|
4270
|
+
st.session_state.pop('df_taxon_table_editor', None)
|
|
4271
|
+
st.session_state.pop('df_metadata_table_editor', None)
|
|
4272
|
+
|
|
4187
4273
|
if 'df_taxon_table' in st.session_state and 'table_display_name' in st.session_state:
|
|
4188
4274
|
st.success(f'Active table: {st.session_state["table_display_name"].stem}')
|
|
4189
4275
|
if st.button('📄 Open Active Table', width='stretch'):
|
|
@@ -4194,6 +4280,15 @@ with st.sidebar:
|
|
|
4194
4280
|
################################################################################################################
|
|
4195
4281
|
st.write(""" # Settings """)
|
|
4196
4282
|
|
|
4283
|
+
################################################################################################################
|
|
4284
|
+
st.write(""" ### Table Format """)
|
|
4285
|
+
format_help_text = (
|
|
4286
|
+
"Excel files (.xlsx) are easy to inspect and edit manually, but can be slow to import, "
|
|
4287
|
+
"especially for large taxon tables. The HDF5 format (.h5) loads much faster and is "
|
|
4288
|
+
"recommended for large datasets, but it is not intended for manual editing."
|
|
4289
|
+
)
|
|
4290
|
+
TTT_tableformat = st.selectbox(label="Select Taxon Table Export Format:", options=[".xlsx", ".h5"], index=[".xlsx", ".h5"].index(TTT_tableformat), key="TTT_tableformat", help=format_help_text)
|
|
4291
|
+
|
|
4197
4292
|
################################################################################################################
|
|
4198
4293
|
st.write(""" ### Presentation """)
|
|
4199
4294
|
# PLOT HEIGHT
|
|
@@ -4246,6 +4341,7 @@ with st.sidebar:
|
|
|
4246
4341
|
|
|
4247
4342
|
settings_keys = [
|
|
4248
4343
|
'TTT_input_path_to_projects',
|
|
4344
|
+
'TTT_tableformat',
|
|
4249
4345
|
'TTT_height',
|
|
4250
4346
|
'TTT_width',
|
|
4251
4347
|
'TTT_showlegend',
|
|
@@ -4305,11 +4401,22 @@ if path_to_projects.exists():
|
|
|
4305
4401
|
selected_taxonomy_table = st.selectbox(label='Select Taxonomy Table', options=import_folder_files.keys(), key='selected_taxonomy_table')
|
|
4306
4402
|
st.selectbox(label='Choose Import Format', options=['APSCALE', 'BOLDigger'], key='taxonomy_table_import_format')
|
|
4307
4403
|
|
|
4308
|
-
st.
|
|
4404
|
+
a1, a2 = st.columns(2)
|
|
4405
|
+
with a1:
|
|
4406
|
+
taxon_table_creation_name = st.text_input(label='Enter Name of Taxon Table', key='taxon_table_creation_name')
|
|
4407
|
+
with a2:
|
|
4408
|
+
st.write('')
|
|
4409
|
+
if st.session_state['TTT_tableformat'] == '.h5':
|
|
4410
|
+
st.info(f'Export Format: {st.session_state["TTT_tableformat"]} (fast, recommended for large tables)')
|
|
4411
|
+
else:
|
|
4412
|
+
st.info(f'Export Format: {st.session_state["TTT_tableformat"]} (editable, slower)')
|
|
4309
4413
|
|
|
4310
4414
|
if selected_read_table and selected_taxonomy_table:
|
|
4311
4415
|
if st.button('Create Taxon Table'):
|
|
4312
|
-
|
|
4416
|
+
if taxon_table_creation_name != '':
|
|
4417
|
+
create_taxon_table()
|
|
4418
|
+
else:
|
|
4419
|
+
st.warning('Please enter a name first!')
|
|
4313
4420
|
|
|
4314
4421
|
########################################################################################################################
|
|
4315
4422
|
|
|
@@ -4319,6 +4426,57 @@ if 'df_taxon_table' in st.session_state and 'table_display_name' in st.session_s
|
|
|
4319
4426
|
available_metadata = st.session_state['df_metadata_table'].columns.tolist()[1:]
|
|
4320
4427
|
st.session_state['taxa_cols2'] = st.session_state['taxa_cols'] + ['Hash']
|
|
4321
4428
|
|
|
4429
|
+
########################################################################################################################
|
|
4430
|
+
# Table Editor
|
|
4431
|
+
st.markdown("## 📄 Taxon Table Editor")
|
|
4432
|
+
|
|
4433
|
+
with st.expander('See more', expanded=False):
|
|
4434
|
+
|
|
4435
|
+
if 'df_taxon_table_editor' not in st.session_state: st.session_state['df_taxon_table_editor'] = st.session_state['df_taxon_table'].copy()
|
|
4436
|
+
if 'df_metadata_table_editor' not in st.session_state: st.session_state['df_metadata_table_editor'] = st.session_state['df_metadata_table'].copy()
|
|
4437
|
+
|
|
4438
|
+
st.success("This section allows you to manually adjust and update your Taxon Table and Metadata Table.")
|
|
4439
|
+
|
|
4440
|
+
col1, col2, col3 = st.columns(3)
|
|
4441
|
+
with col1:
|
|
4442
|
+
editor_table = st.selectbox("Select Table For Editing:", ["Taxon Table", "Metadata Table"], key="editor_table")
|
|
4443
|
+
with col2:
|
|
4444
|
+
editor_add_columns = st.text_input("Add New Trait or Metadata Column:", value="New Metadata")
|
|
4445
|
+
with col3:
|
|
4446
|
+
st.write("")
|
|
4447
|
+
st.write("")
|
|
4448
|
+
if st.button(f'Add Column: "{editor_add_columns}"', use_container_width=True):
|
|
4449
|
+
if editor_table == "Taxon Table":
|
|
4450
|
+
if editor_add_columns not in st.session_state['df_taxon_table_editor'].columns:
|
|
4451
|
+
cols = st.session_state['df_taxon_table_editor'].columns
|
|
4452
|
+
seq_loc = cols.get_loc("Seq")
|
|
4453
|
+
st.session_state['df_taxon_table_editor'].insert(loc=seq_loc, column=editor_add_columns, value="")
|
|
4454
|
+
else:
|
|
4455
|
+
if editor_add_columns not in st.session_state['df_metadata_table_editor'].columns:
|
|
4456
|
+
st.session_state['df_metadata_table_editor'].insert(loc=1, column=editor_add_columns, value="")
|
|
4457
|
+
|
|
4458
|
+
# ---------------------------
|
|
4459
|
+
# Show editor WITHOUT updating session_state yet
|
|
4460
|
+
# ---------------------------
|
|
4461
|
+
if editor_table == "Taxon Table":
|
|
4462
|
+
edited_df = st.data_editor(st.session_state['df_taxon_table_editor'], height=800, key="taxon_editor")
|
|
4463
|
+
else:
|
|
4464
|
+
edited_df = st.data_editor(st.session_state['df_metadata_table_editor'], height=800, key="meta_editor")
|
|
4465
|
+
|
|
4466
|
+
# ---------------------------
|
|
4467
|
+
# Apply edits only when user clicks 'Submit'
|
|
4468
|
+
# ---------------------------
|
|
4469
|
+
if st.button("💾 Apply Changes To File", width='stretch'):
|
|
4470
|
+
edited_df = edited_df.fillna('')
|
|
4471
|
+
if editor_table == "Taxon Table":
|
|
4472
|
+
st.session_state['df_taxon_table'] = edited_df.copy()
|
|
4473
|
+
export_taxon_table(st.session_state['table_display_name'], edited_df, st.session_state['df_metadata_table'], '', st.session_state['TTT_tableformat'])
|
|
4474
|
+
st.success("Taxon Table updated!")
|
|
4475
|
+
else:
|
|
4476
|
+
st.session_state['df_metadata_table'] = edited_df.copy()
|
|
4477
|
+
export_taxon_table(st.session_state['table_display_name'], st.session_state['df_taxon_table'], edited_df, '', st.session_state['TTT_tableformat'])
|
|
4478
|
+
st.success("Metadata Table updated!")
|
|
4479
|
+
|
|
4322
4480
|
########################################################################################################################
|
|
4323
4481
|
st.markdown("## 🖥️ Basic Stats")
|
|
4324
4482
|
with st.expander(expanded=True, label='See more'):
|
|
@@ -4507,6 +4665,16 @@ if 'df_taxon_table' in st.session_state and 'table_display_name' in st.session_s
|
|
|
4507
4665
|
sample_filter()
|
|
4508
4666
|
st.divider()
|
|
4509
4667
|
|
|
4668
|
+
st.write('### Remove Low Coverage Samples')
|
|
4669
|
+
col1, col2 = st.columns([2,6])
|
|
4670
|
+
with col1:
|
|
4671
|
+
lc_threshold = st.number_input(label='Minimum Sequencing Depth per Sample:', value=0, min_value=0, key='lc_threshold')
|
|
4672
|
+
with col2:
|
|
4673
|
+
st.write('')
|
|
4674
|
+
st.info(f'Samples with <= {lc_threshold} reads will be discarded from the Taxon Table.')
|
|
4675
|
+
if st.button('🔄 Remove Low-coverage Samples', width='stretch'):
|
|
4676
|
+
empty_sample_remove()
|
|
4677
|
+
st.divider()
|
|
4510
4678
|
|
|
4511
4679
|
st.write('### Trait Filter')
|
|
4512
4680
|
col1, col2 = st.columns([2,6])
|
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: taxontabletools2
|
|
3
|
-
Version: 2.3.
|
|
3
|
+
Version: 2.3.4
|
|
4
4
|
Summary: Taxontabletools2 - A comprehensive, platform-independent graphical user interface software to explore and visualise DNA metabarcoding data
|
|
5
5
|
Home-page: https://pypi.org/project/taxontabletools2
|
|
6
6
|
Author: Till-Hendrik Macher
|
|
@@ -12,9 +12,11 @@ Classifier: Operating System :: OS Independent
|
|
|
12
12
|
Requires-Python: >=3.10
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
License-File: LICENSE
|
|
15
|
-
Requires-Dist: streamlit
|
|
15
|
+
Requires-Dist: streamlit>=1.54.0
|
|
16
16
|
Requires-Dist: stqdm
|
|
17
17
|
Requires-Dist: pygbif
|
|
18
|
+
Requires-Dist: tables
|
|
19
|
+
Requires-Dist: streamlit-sortables
|
|
18
20
|
Requires-Dist: geopandas
|
|
19
21
|
Requires-Dist: scikit-learn
|
|
20
22
|
Requires-Dist: xlsxwriter
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{taxontabletools2-2.3.2 → taxontabletools2-2.3.4}/taxontabletools2/Rscripts/internal/.DS_Store
RENAMED
|
File without changes
|
{taxontabletools2-2.3.2 → taxontabletools2-2.3.4}/taxontabletools2/Rscripts/internal/efiminus.R
RENAMED
|
File without changes
|
{taxontabletools2-2.3.2 → taxontabletools2-2.3.4}/taxontabletools2/Rscripts/internal/internal.zip
RENAMED
|
File without changes
|
|
File without changes
|
{taxontabletools2-2.3.2 → taxontabletools2-2.3.4}/taxontabletools2/WFD_conversion/efi_ecoregions.png
RENAMED
|
File without changes
|
{taxontabletools2-2.3.2 → taxontabletools2-2.3.4}/taxontabletools2/WFD_conversion/efi_table.xlsx
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{taxontabletools2-2.3.2 → taxontabletools2-2.3.4}/taxontabletools2/taxonomy_table_example.xlsx
RENAMED
|
File without changes
|
|
File without changes
|
{taxontabletools2-2.3.2 → taxontabletools2-2.3.4}/taxontabletools2.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{taxontabletools2-2.3.2 → taxontabletools2-2.3.4}/taxontabletools2.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|