BioSAK 1.78.4__tar.gz → 1.79.0__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.
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/VERSION +4 -1
- BioSAK-1.79.0/BioSAK/boxplot.py +82 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/enrich.py +9 -6
- BioSAK-1.79.0/BioSAK/subset_df.py +91 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK.egg-info/PKG-INFO +2 -2
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK.egg-info/SOURCES.txt +2 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/PKG-INFO +2 -2
- {BioSAK-1.78.4 → BioSAK-1.79.0}/bin/BioSAK +13 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/BLCA_op_parser.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/BioSAK_config.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/COG2020.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/COG_boxplot_last1row.R +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/COG_boxplot_last2row.R +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/CheckM.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/ConvertMSA.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/DnaFeaturesViewer.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/FastaSplitler_by_num.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/FastaSplitler_by_size.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/GTDB_for_BLCA.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/Gene2Ctg.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/KEGG.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/KEGG_boxplot_last1row.R +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/KEGG_get_eukaryotic_kos.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/KeepRemovingTmp.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/MeanMappingDepth.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/MetaBiosample.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/MetaCHIP_phylo.hmm +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/MetaCyc_reactions_with_ec.txt +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/NetEnzymes.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/Newick_tree_plotter.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/OneLineAln.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/Prodigal.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/Reads_simulator.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/RunGraphMB.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/SILVA_for_BLCA.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/SankeyTaxon.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/SliceMSA.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/SubsampleLongReads.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/Tax4Fun2IndOTU.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/VisBlastOp.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/VisGeneFlk.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/__init__.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/arCOG.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/bam2reads.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/boxplot_last1row.R +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/boxplot_matrix_COG.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/boxplot_matrix_COG_backup.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/boxplot_matrix_KEGG.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/boxplot_matrix_dbCAN.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/cat_fa.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/cdd2cog.pl +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/checkm_marker.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/compare_trees.R +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/compare_trees.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/cross_link_seqs.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/dbCAN.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/download_GenBank_genome_subset_prokaryotes_csv.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/dwnld_sra_reads.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/exe_cmds.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/ezaai2mat.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/fa2id.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/fa2phy.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/fa2tree.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/format_converter.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/format_leaf_name.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/fq2fa.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/gbk2faa.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/gbk2ffn.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/gbk2fna.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/gbk_to_ffn_faa.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/get_EC_from_ko_stats_D.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/get_GTDB_taxon_gnm.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/get_MAG_reads_long.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/get_Pfam_hmms.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/get_SCG_tree.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/get_TopHits_taxonomy.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/get_aa_composition.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/get_bin_abundance copy.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/get_data_matrix.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/get_gc.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/get_gene_depth.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/get_genome_GTDB.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/get_genome_NCBI.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/get_genome_NCBI_v1.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/get_genome_NCBI_v2.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/get_gnm_size.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/get_ko_gene_seqs.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/get_krona_plot.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/get_reads_from_sam.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/get_reads_id_in_sam.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/get_sankey_plot.R +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/get_top_hit.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/get_total_length.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/global_functions.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/hpc3.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/iTOL.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/js_cmds.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/js_hpc3.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/keep_best_hit.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/ko00001.keg +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/koala.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/label_tree.R +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/label_tree.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/link_16S_MAG.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/magabund.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/magabund2.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/manipulator_fasta.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/manipulator_msa.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/manipulator_newick.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/manipulator_sam.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/mean_MAG_cov.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/merge_seq.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/metaAssembly.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/metabat2concoct.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/metabat2maxbin.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/msa_to_distance_matrix.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/ncbi_dataset.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/odp.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/parse_MetaCyc_RxnDB.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/parse_mmseqs_tsv.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/plot_mag.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/plot_sam_depth.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/plot_tree.R +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/prefix_file.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/prokka.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/reads2bam.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/rename_leaves.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/rename_reads_for_Reago.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/rename_seq.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/rename_seqs.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/ribbon.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/sam2bam.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/sampling_GTDB_gnms.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/select_seq.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/sep_reads_by_barcode.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/slice_seq.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/split_fasta.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/split_folder.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/split_sam.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/submitHPC.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/subset_GTDB_meta.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/subset_tree.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/top_16S_hits.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/top_hits_in_a_group.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK/usearch_uc.py +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK.egg-info/dependency_links.txt +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK.egg-info/requires.txt +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/BioSAK.egg-info/top_level.txt +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/LICENSE +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/MANIFEST.in +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/README.md +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/setup.cfg +0 -0
- {BioSAK-1.78.4 → BioSAK-1.79.0}/setup.py +0 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import numpy as np
|
|
3
|
+
import matplotlib as mpl
|
|
4
|
+
mpl.use('Agg')
|
|
5
|
+
import matplotlib.pyplot as plt
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
boxplot_usage = '''
|
|
9
|
+
===================== boxplot example commands =====================
|
|
10
|
+
|
|
11
|
+
python3 boxplot_with_dots.py -i demo_boxplot.txt -o boxplot.pdf
|
|
12
|
+
python3 boxplot_with_dots.py -i demo_boxplot.txt -o boxplot.pdf -d
|
|
13
|
+
|
|
14
|
+
# format of input file (tab separated, no row name)
|
|
15
|
+
Apple Banana Orange
|
|
16
|
+
1 4 6
|
|
17
|
+
2 5 7
|
|
18
|
+
3 6 8
|
|
19
|
+
4 7 9
|
|
20
|
+
|
|
21
|
+
====================================================================
|
|
22
|
+
'''
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def boxplot_with_dots(args):
|
|
26
|
+
|
|
27
|
+
data_file = args['i']
|
|
28
|
+
add_dots = args['d']
|
|
29
|
+
output_plot = args['o']
|
|
30
|
+
|
|
31
|
+
# read in file
|
|
32
|
+
data_dict = dict()
|
|
33
|
+
col_index = dict()
|
|
34
|
+
line_num_index = 0
|
|
35
|
+
for each_line in open(data_file):
|
|
36
|
+
line_num_index += 1
|
|
37
|
+
line_split = each_line.strip().split('\t')
|
|
38
|
+
if line_num_index == 1:
|
|
39
|
+
col_index = {key: i for key, i in enumerate(line_split)}
|
|
40
|
+
data_dict = {i: [] for key, i in enumerate(line_split)}
|
|
41
|
+
else:
|
|
42
|
+
element_pos = 0
|
|
43
|
+
for each_element in line_split:
|
|
44
|
+
grp = col_index[element_pos]
|
|
45
|
+
print('%s\t%s\t%s' % (grp, element_pos, each_element))
|
|
46
|
+
data_dict[grp].append(float(each_element))
|
|
47
|
+
element_pos += 1
|
|
48
|
+
|
|
49
|
+
# get label
|
|
50
|
+
name_list = sorted(list(data_dict.keys()))
|
|
51
|
+
num_lol = [data_dict[i] for i in name_list]
|
|
52
|
+
|
|
53
|
+
# plot
|
|
54
|
+
data = [np.array(i) for i in num_lol]
|
|
55
|
+
box_plot = plt.boxplot(data, labels=name_list, patch_artist=True, whiskerprops=dict(color='black', linewidth=1), capprops=dict(color='black'))
|
|
56
|
+
|
|
57
|
+
# set the color pf box
|
|
58
|
+
for box in box_plot['boxes']:
|
|
59
|
+
box.set(linewidth=1)
|
|
60
|
+
box.set_facecolor('white')
|
|
61
|
+
|
|
62
|
+
# add dots, https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.plot.html
|
|
63
|
+
if add_dots is True:
|
|
64
|
+
col_index = 1
|
|
65
|
+
for num_arrary in data:
|
|
66
|
+
plt.plot(np.random.normal(col_index, 0.02, len(num_arrary)), num_arrary, '.', alpha=0.8, color='orange', markersize=6, markeredgewidth=0)
|
|
67
|
+
col_index += 1
|
|
68
|
+
|
|
69
|
+
# write out
|
|
70
|
+
plt.tight_layout()
|
|
71
|
+
plt.savefig(output_plot, bbox_inches='tight', dpi=300)
|
|
72
|
+
plt.close()
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
if __name__ == '__main__':
|
|
76
|
+
|
|
77
|
+
boxplot_parser = argparse.ArgumentParser()
|
|
78
|
+
boxplot_parser.add_argument('-i', required=True, help='input files')
|
|
79
|
+
boxplot_parser.add_argument('-d', required=False, action="store_true", help='show dots')
|
|
80
|
+
boxplot_parser.add_argument('-o', required=True, help='output plot')
|
|
81
|
+
args = vars(boxplot_parser.parse_args())
|
|
82
|
+
boxplot_with_dots(args)
|
|
@@ -11,7 +11,9 @@ enrich_usage = '''
|
|
|
11
11
|
|
|
12
12
|
BioSAK enrich -i annotation_files -x txt -g grouping.txt -o output_dir -bc
|
|
13
13
|
|
|
14
|
-
#
|
|
14
|
+
# Note:
|
|
15
|
+
1. The number of genome groups has to be TWO!!!
|
|
16
|
+
2. Group name should NOT be 1 and 0. use some alphabet or words instead.
|
|
15
17
|
|
|
16
18
|
# Example input files:
|
|
17
19
|
https://github.com/songweizhi/BioSAK/tree/master/demo_data/enrich
|
|
@@ -234,16 +236,19 @@ def enrich(args):
|
|
|
234
236
|
ko_id_list = []
|
|
235
237
|
col_index = 0
|
|
236
238
|
for column in column_list:
|
|
237
|
-
if col_index >=
|
|
239
|
+
if col_index >= 1:
|
|
240
|
+
print('Processing %s/%s: %s' % ((col_index - 1), len(column_list)-1, column))
|
|
238
241
|
group1 = df.where(df.Group == group_1_id).dropna()[column]
|
|
239
242
|
group2 = df.where(df.Group == group_2_id).dropna()[column]
|
|
243
|
+
|
|
244
|
+
# to calculate the presence coverage, nothing about the enrichment stats
|
|
240
245
|
group1_no_zero_pct = len(remove_0_from_Pandas_Series(group1))*100/len(group1)
|
|
241
246
|
group2_no_zero_pct = len(remove_0_from_Pandas_Series(group2))*100/len(group2)
|
|
242
247
|
group1_no_zero_pct = float("{0:.2f}".format(group1_no_zero_pct))
|
|
243
248
|
group2_no_zero_pct = float("{0:.2f}".format(group2_no_zero_pct))
|
|
244
249
|
ko_to_group_detected_pct_dict[column] = [group1_no_zero_pct, group2_no_zero_pct]
|
|
245
|
-
|
|
246
|
-
print('
|
|
250
|
+
# print('%s\t%s\t%s' % (column, group_1_id, list(group1)))
|
|
251
|
+
# print('%s\t%s\t%s' % (column, group_2_id, list(group2)))
|
|
247
252
|
|
|
248
253
|
# store group mean into dict
|
|
249
254
|
group1_mean = float("{0:.2f}".format(sum(group1) / len(group1)))
|
|
@@ -271,12 +276,10 @@ def enrich(args):
|
|
|
271
276
|
current_p_adjusted = float("{0:.3f}".format(p_value_list_adjusted[x]))
|
|
272
277
|
current_p_group_mean = [str(i) for i in ko_to_group_mean_dict[ko_id_list[x]]]
|
|
273
278
|
current_p_detected_pct = [str(i) for i in ko_to_group_detected_pct_dict[ko_id_list[x]]]
|
|
274
|
-
|
|
275
279
|
group_1_mean = current_p_group_mean[0]
|
|
276
280
|
group_2_mean = current_p_group_mean[1]
|
|
277
281
|
group_1_no_zero_pct = current_p_detected_pct[0]
|
|
278
282
|
group_2_no_zero_pct = current_p_detected_pct[1]
|
|
279
|
-
|
|
280
283
|
output_test_handle.write('%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' % (ko_id_list[x], group_1_mean, group_1_no_zero_pct, group_2_mean, group_2_no_zero_pct, current_p, current_p_adjusted, ko_desc_dict[ko_id_list[x]]))
|
|
281
284
|
x += 1
|
|
282
285
|
output_test_handle.close()
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import argparse
|
|
3
|
+
import pandas as pd
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
subset_df_usage = '''
|
|
7
|
+
================================== subset_df example commands ==================================
|
|
8
|
+
|
|
9
|
+
BioSAK subset_df -i demo_df.txt -r rows_to_keep.txt -o df_subset.txt
|
|
10
|
+
BioSAK subset_df -i demo_df.txt -c cols_to_keep.txt -o df_subset.txt
|
|
11
|
+
BioSAK subset_df -i demo_df.txt -r rows_to_keep.txt -c cols_to_keep.txt -o df_subset.txt
|
|
12
|
+
BioSAK subset_df -i demo_df.txt -r rows_to_keep.txt -c cols_to_keep.txt -o df_subset.txt -b -m
|
|
13
|
+
|
|
14
|
+
================================================================================================
|
|
15
|
+
'''
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def subset_df(args):
|
|
19
|
+
|
|
20
|
+
file_in = args['i']
|
|
21
|
+
file_out = args['o']
|
|
22
|
+
rows_to_keep_file = args['r']
|
|
23
|
+
cols_to_keep_file = args['c']
|
|
24
|
+
df_separator = args['s']
|
|
25
|
+
in_binary = args['b']
|
|
26
|
+
zero_as_minus_one = args['m']
|
|
27
|
+
column_name_pos = 0
|
|
28
|
+
row_name_pos = 0
|
|
29
|
+
|
|
30
|
+
# read in rows_to_keep_file
|
|
31
|
+
rows_to_keep_set = set()
|
|
32
|
+
if os.path.isfile(rows_to_keep_file) is True:
|
|
33
|
+
for each_r in open(rows_to_keep_file):
|
|
34
|
+
rows_to_keep_set.add(each_r.strip().split()[0])
|
|
35
|
+
|
|
36
|
+
# read in cols_to_keep_file
|
|
37
|
+
cols_to_keep_set = set()
|
|
38
|
+
if os.path.isfile(cols_to_keep_file) is True:
|
|
39
|
+
for each_c in open(cols_to_keep_file):
|
|
40
|
+
cols_to_keep_set.add(each_c.strip().split()[0])
|
|
41
|
+
|
|
42
|
+
# turn sets into lists
|
|
43
|
+
rows_to_keep_list_sorted = sorted(list(rows_to_keep_set))
|
|
44
|
+
cols_to_keep_list_sorted = sorted(list(cols_to_keep_set))
|
|
45
|
+
|
|
46
|
+
# setup separator
|
|
47
|
+
if df_separator in ['tab', 'Tab', 'TAB']:
|
|
48
|
+
sep_symbol = '\t'
|
|
49
|
+
elif df_separator in ['comma', 'Comma', 'COMMA']:
|
|
50
|
+
sep_symbol = ','
|
|
51
|
+
else:
|
|
52
|
+
print('Please specify separator as either tab or comma, program exited!')
|
|
53
|
+
exit()
|
|
54
|
+
|
|
55
|
+
# read in df
|
|
56
|
+
df = pd.read_csv(file_in, sep=sep_symbol, header=column_name_pos, index_col=row_name_pos)
|
|
57
|
+
|
|
58
|
+
if len(rows_to_keep_list_sorted) == 0:
|
|
59
|
+
if len(cols_to_keep_list_sorted) == 0:
|
|
60
|
+
subset_df = df.loc[:, :]
|
|
61
|
+
else:
|
|
62
|
+
subset_df = df.loc[:, cols_to_keep_list_sorted]
|
|
63
|
+
else:
|
|
64
|
+
if len(cols_to_keep_list_sorted) == 0:
|
|
65
|
+
subset_df = df.loc[rows_to_keep_list_sorted, :]
|
|
66
|
+
else:
|
|
67
|
+
subset_df = df.loc[rows_to_keep_list_sorted, cols_to_keep_list_sorted]
|
|
68
|
+
|
|
69
|
+
if in_binary is True:
|
|
70
|
+
subset_df[subset_df <= 0] = 0
|
|
71
|
+
subset_df[subset_df > 0] = 1
|
|
72
|
+
|
|
73
|
+
# turn 0 to -1
|
|
74
|
+
if zero_as_minus_one is True:
|
|
75
|
+
subset_df[subset_df == 0] = -1
|
|
76
|
+
|
|
77
|
+
subset_df.to_csv(file_out, sep=sep_symbol)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
if __name__ == '__main__':
|
|
81
|
+
|
|
82
|
+
subset_df_parser = argparse.ArgumentParser(usage=subset_df_usage)
|
|
83
|
+
subset_df_parser.add_argument('-i', required=True, help='input file')
|
|
84
|
+
subset_df_parser.add_argument('-o', required=True, help='output file')
|
|
85
|
+
subset_df_parser.add_argument('-r', required=False, default=None, help='header of rows to keep')
|
|
86
|
+
subset_df_parser.add_argument('-c', required=False, default=None, help='header of columns to keep')
|
|
87
|
+
subset_df_parser.add_argument('-s', required=False, default='tab', help='column separator, choose from tab and comma, default: tab')
|
|
88
|
+
subset_df_parser.add_argument('-b', required=False, action='store_true', help='write out dataframe in 0/1 format')
|
|
89
|
+
subset_df_parser.add_argument('-m', required=False, action='store_true', help='convert 0 to -1')
|
|
90
|
+
args = vars(subset_df_parser.parse_args())
|
|
91
|
+
subset_df(args)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: BioSAK
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.79.0
|
|
4
4
|
Summary: BioSAK
|
|
5
5
|
Home-page: https://github.com/songweizhi/BioSAK
|
|
6
6
|
Author: Weizhi Song
|
|
@@ -20,4 +20,4 @@ Requires-Dist: beautifulsoup4
|
|
|
20
20
|
Requires-Dist: ete3
|
|
21
21
|
Requires-Dist: statsmodels
|
|
22
22
|
|
|
23
|
-
BioSAK v1.
|
|
23
|
+
BioSAK v1.79.0
|
|
@@ -39,6 +39,7 @@ BioSAK/VisGeneFlk.py
|
|
|
39
39
|
BioSAK/__init__.py
|
|
40
40
|
BioSAK/arCOG.py
|
|
41
41
|
BioSAK/bam2reads.py
|
|
42
|
+
BioSAK/boxplot.py
|
|
42
43
|
BioSAK/boxplot_last1row.R
|
|
43
44
|
BioSAK/boxplot_matrix_COG.py
|
|
44
45
|
BioSAK/boxplot_matrix_COG_backup.py
|
|
@@ -137,6 +138,7 @@ BioSAK/split_folder.py
|
|
|
137
138
|
BioSAK/split_sam.py
|
|
138
139
|
BioSAK/submitHPC.py
|
|
139
140
|
BioSAK/subset_GTDB_meta.py
|
|
141
|
+
BioSAK/subset_df.py
|
|
140
142
|
BioSAK/subset_tree.py
|
|
141
143
|
BioSAK/top_16S_hits.py
|
|
142
144
|
BioSAK/top_hits_in_a_group.py
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: BioSAK
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.79.0
|
|
4
4
|
Summary: BioSAK
|
|
5
5
|
Home-page: https://github.com/songweizhi/BioSAK
|
|
6
6
|
Author: Weizhi Song
|
|
@@ -20,4 +20,4 @@ Requires-Dist: beautifulsoup4
|
|
|
20
20
|
Requires-Dist: ete3
|
|
21
21
|
Requires-Dist: statsmodels
|
|
22
22
|
|
|
23
|
-
BioSAK v1.
|
|
23
|
+
BioSAK v1.79.0
|
|
@@ -915,6 +915,19 @@ if __name__ == '__main__':
|
|
|
915
915
|
args = vars(parser.parse_args())
|
|
916
916
|
koala.koala(args)
|
|
917
917
|
|
|
918
|
+
elif sys.argv[1] == 'subset_df':
|
|
919
|
+
from BioSAK import subset_df
|
|
920
|
+
subset_df_parser = subparsers.add_parser('subset_df', usage=subset_df.subset_df_usage)
|
|
921
|
+
subset_df_parser.add_argument('-i', required=True, help='input file')
|
|
922
|
+
subset_df_parser.add_argument('-o', required=True, help='output file')
|
|
923
|
+
subset_df_parser.add_argument('-r', required=False, default=None, help='header of rows to keep')
|
|
924
|
+
subset_df_parser.add_argument('-c', required=False, default=None, help='header of columns to keep')
|
|
925
|
+
subset_df_parser.add_argument('-s', required=False, default='tab', help='column separator, choose from tab and comma, default: tab')
|
|
926
|
+
subset_df_parser.add_argument('-b', required=False, action='store_true', help='write out dataframe in 0/1 format')
|
|
927
|
+
subset_df_parser.add_argument('-m', required=False, action='store_true', help='convert 0 to -1')
|
|
928
|
+
args = vars(parser.parse_args())
|
|
929
|
+
subset_df.subset_df(args)
|
|
930
|
+
|
|
918
931
|
else:
|
|
919
932
|
print('Unrecognized command: %s, program exited' % sys.argv[1])
|
|
920
933
|
exit()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|