-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorganize_dir_structure_others.sh
executable file
·223 lines (179 loc) · 15.2 KB
/
organize_dir_structure_others.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
#/bin/sh -S
#########
#Please address any bugs to Cheng.
#Date 2017.12.19
#########
mapping_file=$1
category_1=$2
SCRIPTPATH=$3
number=$4
prefix=$5
if [ -z "$3" ]; then
echo "##########
Please prepare the directory structure before starting the program like below:
raw/fastq_files ...
mapping_file
manifest_file
\n\n"
echo "Please provide following input parameters
1) Full path of the mapping file. (Accept both .csv or txt format.)
2) The name of the first category in the mapping file.
Sample Usage:
sh $0 M231_Mapping_2.tsv Group1 readme.pdf
"
exit 0
else
echo "################
Running: sh $0 $1 $2 $3"
fi
check_file() {
echo "Checking file for $1 ..."
file_name=$1
if [ -f $file_name ]; then
echo "File $file_name exists"
else
echo "File $file_name does not exist"
exit
fi
}
echo "##############################################################\n#Organize the Result folder"
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
if [ -d "./Result_AmpliconSequencing" ];then
rm -r ./Result_AmpliconSequencing;
fi;
mkdir -p ./Result_AmpliconSequencing/ \
./Result_AmpliconSequencing/2-AbundanceAnalysis/ ./Result_AmpliconSequencing/2-AbundanceAnalysis/1-AbundanceSummary/1-AbundanceTable/1-Absolute/ \
./Result_AmpliconSequencing/2-AbundanceAnalysis/1-AbundanceSummary/1-AbundanceTable/2-Relative/ \
./Result_AmpliconSequencing/2-AbundanceAnalysis/1-AbundanceSummary/1-AbundanceTable/3-CollapsedStats/ \
./Result_AmpliconSequencing/2-AbundanceAnalysis/1-AbundanceSummary/2-Barplots/ \
./Result_AmpliconSequencing/2-AbundanceAnalysis/1-AbundanceSummary/3-Heatmaps/Heatmap-Qiime2/ \
./Result_AmpliconSequencing/2-AbundanceAnalysis/2-AbundanceComparison/1-ANCOM/ \
./Result_AmpliconSequencing/2-AbundanceAnalysis/2-AbundanceComparison/2-ANOVA/ \
./Result_AmpliconSequencing/2-AbundanceAnalysis/2-AbundanceComparison/3-KruskalWallis/ \
./Result_AmpliconSequencing/2-AbundanceAnalysis/2-AbundanceComparison/4-LEfSe/ \
./Result_AmpliconSequencing/2-AbundanceAnalysis/2-AbundanceComparison/5-DESeq2/ \
./Result_AmpliconSequencing/3-AlphaDiversity/1-AlphaDiversitySummary/ \
./Result_AmpliconSequencing/3-AlphaDiversity/2-AlphaRarefaction/ \
./Result_AmpliconSequencing/3-AlphaDiversity/3-SignificanceAnalysis/1-Wilcox_Test/ \
./Result_AmpliconSequencing/3-AlphaDiversity/3-SignificanceAnalysis/2-Kruskal_Wallis/ \
./Result_AmpliconSequencing/4-BetaDiversity/1-BetaDiversitySummary/ \
./Result_AmpliconSequencing/4-BetaDiversity/2-PCoA/ \
./Result_AmpliconSequencing/4-BetaDiversity/3-NMDS/ \
./Result_AmpliconSequencing/4-BetaDiversity/4-PLS-DA/ \
./Result_AmpliconSequencing/4-BetaDiversity/5-GroupSignificance/ \
./Result_AmpliconSequencing/4-BetaDiversity/6-PCA/ \
./Result_AmpliconSequencing/5-Phylogenetics/ \
./Result_AmpliconSequencing/6-AssociationAnalysis/1-RDA/ \
./Result_AmpliconSequencing/7-FiguresTablesForReport \
./Result_AmpliconSequencing/4-BetaDiversity/2-PCoA/PCoA-Phyloseq \
./Result_AmpliconSequencing/4-BetaDiversity/2-PCoA/PCoA-Qiime2 \
echo "Start organize the files for deliverables ..."
cp ${SCRIPTPATH}/Result_README.pdf ./Result_AmpliconSequencing/
cp $mapping_file ./Result_AmpliconSequencing/mapping_file.txt
cp exported/Absolute/*absolute.txt ./Result_AmpliconSequencing/2-AbundanceAnalysis/1-AbundanceSummary/1-AbundanceTable/1-Absolute/
#cp exported/Absolute/otu_table.p.absolute.mat ./Result_AmpliconSequencing/2-AbundanceAnalysis/1-AbundanceSummary/1-AbundanceTable/1-Absolute/feature-table.Phylum.absolute.txt
#cp exported/Absolute/otu_table.c.absolute.mat ./Result_AmpliconSequencing/2-AbundanceAnalysis/1-AbundanceSummary/1-AbundanceTable/1-Absolute/feature-table.Class.absolute.txt
#cp exported/Absolute/otu_table.o.absolute.mat ./Result_AmpliconSequencing/2-AbundanceAnalysis/1-AbundanceSummary/1-AbundanceTable/1-Absolute/feature-table.Order.absolute.txt
#cp exported/Absolute/otu_table.f.absolute.mat ./Result_AmpliconSequencing/2-AbundanceAnalysis/1-AbundanceSummary/1-AbundanceTable/1-Absolute/feature-table.Family.absolute.txt
#cp exported/Absolute/otu_table.g.absolute.mat ./Result_AmpliconSequencing/2-AbundanceAnalysis/1-AbundanceSummary/1-AbundanceTable/1-Absolute/feature-table.Genus.absolute.txt
#cp exported/Absolute/otu_table.s.absolute.mat ./Result_AmpliconSequencing/2-AbundanceAnalysis/1-AbundanceSummary/1-AbundanceTable/1-Absolute/feature-table.Species.absolute.txt
cp exported/Relative/*relative.txt ./Result_AmpliconSequencing/2-AbundanceAnalysis/1-AbundanceSummary/1-AbundanceTable/2-Relative/
#cp exported/Relative/otu_table.p.relative.mat ./Result_AmpliconSequencing/2-AbundanceAnalysis/1-AbundanceSummary/1-AbundanceTable/2-Relative/feature-table.Phylum.relative.txt
#cp exported/Relative/otu_table.c.relative.mat ./Result_AmpliconSequencing/2-AbundanceAnalysis/1-AbundanceSummary/1-AbundanceTable/2-Relative/feature-table.Class.relative.txt
#cp exported/Relative/otu_table.o.relative.mat ./Result_AmpliconSequencing/2-AbundanceAnalysis/1-AbundanceSummary/1-AbundanceTable/2-Relative/feature-table.Order.relative.txt
#cp exported/Relative/otu_table.f.relative.mat ./Result_AmpliconSequencing/2-AbundanceAnalysis/1-AbundanceSummary/1-AbundanceTable/2-Relative/feature-table.Family.relative.txt
#cp exported/Relative/otu_table.g.relative.mat ./Result_AmpliconSequencing/2-AbundanceAnalysis/1-AbundanceSummary/1-AbundanceTable/2-Relative/feature-table.Genus.relative.txt
#cp exported/Relative/otu_table.s.relative.mat ./Result_AmpliconSequencing/2-AbundanceAnalysis/1-AbundanceSummary/1-AbundanceTable/2-Relative/feature-table.Species.relative.txt
cp -r exported/collapsed/*qzv* ./Result_AmpliconSequencing/2-AbundanceAnalysis/1-AbundanceSummary/1-AbundanceTable/3-CollapsedStats/
cp -r taxa-bar-plots.qzv* ./Result_AmpliconSequencing/2-AbundanceAnalysis/1-AbundanceSummary/2-Barplots/
#cp -r exported/Relative/*relative.txt exported/Relative/otu*png ./Result_AmpliconSequencing/2-AbundanceAnalysis/1-AbundanceSummary/2-Barplots/taxa-bar-plots-top20
cp -r exported/${number}/*.qzv* ./Result_AmpliconSequencing/2-AbundanceAnalysis/1-AbundanceSummary/3-Heatmaps/Heatmap-Qiime2/
cp -r Heatmap_top20 ./Result_AmpliconSequencing/2-AbundanceAnalysis/1-AbundanceSummary/3-Heatmaps/
cp -r exported/ANCOM/*.qzv* ./Result_AmpliconSequencing/2-AbundanceAnalysis/2-AbundanceComparison/1-ANCOM/
cp -r exported/DiffAbundance/ANOVA_*txt ./Result_AmpliconSequencing/2-AbundanceAnalysis/2-AbundanceComparison/2-ANOVA/
cp -r exported/DiffAbundance/kruskal_wallis_*txt ./Result_AmpliconSequencing/2-AbundanceAnalysis/2-AbundanceComparison/3-KruskalWallis/
#cp lefse result ./Result_AmpliconSequencing/2-AbundanceAnalysis/2-AbundanceComparison/4-LEfSe/
cp -r exported/Relative/Lefse/*/ ./Result_AmpliconSequencing/2-AbundanceAnalysis/2-AbundanceComparison/4-LEfSe/
cp -r exported/DiffAbundance/DESeq2_*txt ./Result_AmpliconSequencing/2-AbundanceAnalysis/2-AbundanceComparison/5-DESeq2/
cp -r alpha/alpha-summary.tsv R_output/*alpha_diversity_* ./Result_AmpliconSequencing/3-AlphaDiversity/1-AlphaDiversitySummary/
cp -r alpha-rarefaction.qzv* ./Result_AmpliconSequencing/3-AlphaDiversity/2-AlphaRarefaction/
cp -r alpha/*wilcox* ./Result_AmpliconSequencing/3-AlphaDiversity/3-SignificanceAnalysis/1-Wilcox_Test/
cp -r core-metrics-results/observed*qzv* ./Result_AmpliconSequencing/3-AlphaDiversity/3-SignificanceAnalysis/2-Kruskal_Wallis/
cp -r core-metrics-results/shannon*qzv* ./Result_AmpliconSequencing/3-AlphaDiversity/3-SignificanceAnalysis/2-Kruskal_Wallis/
cp -r core-metrics-results/faith*qzv* ./Result_AmpliconSequencing/3-AlphaDiversity/3-SignificanceAnalysis/2-Kruskal_Wallis/
cp -r R_output/*matrix.txt R_output/BetaDiversity_heatmap.png ./Result_AmpliconSequencing/4-BetaDiversity/1-BetaDiversitySummary/
cp -r R_output/*summary.pdf ./Result_AmpliconSequencing/4-BetaDiversity/1-BetaDiversitySummary/
cp -r core-metrics-results/*_emperor.qzv* ./Result_AmpliconSequencing/4-BetaDiversity/2-PCoA/PCoA-Qiime2
cp -r R_output/*PCoA* ./Result_AmpliconSequencing/4-BetaDiversity/2-PCoA/PCoA-Phyloseq
cp -r R_output/*NMDS* ./Result_AmpliconSequencing/4-BetaDiversity/3-NMDS/
cp -r core-metrics-results/*permanova*significance.qzv* ./Result_AmpliconSequencing/4-BetaDiversity/5-GroupSignificance/
cp -r core-metrics-results/*anosim*significance.qzv* ./Result_AmpliconSequencing/4-BetaDiversity/5-GroupSignificance/
#cp -r R_output/unifrac*summary.pdf ./Result_AmpliconSequencing/4-BetaDiversity/1-BetaDiversitySummary/
#cp -r core-metrics-results/unweighted*_emperor.qzv* R_output/*unifrac*PCoA* ./Result_AmpliconSequencing/4-BetaDiversity/2-PCoA/
#cp -r R_output/*unifrac*NMDS* ./Result_AmpliconSequencing/4-BetaDiversity/3-NMDS/
#cp -r core-metrics-results/unweighted*significance.qzv* ./Result_AmpliconSequencing/4-BetaDiversity/5-GroupSignificance/
#cp -r R_output/wunifrac*summary.pdf ./Result_AmpliconSequencing/4-BetaDiversity/1-BetaDiversitySummary/
#cp -r core-metrics-results/weighted*_emperor.qzv* R_output/*wunifrac*PCoA* ./Result_AmpliconSequencing/4-BetaDiversity/2-PCoA/
#cp -r R_output/*wunifrac*NMDS* ./Result_AmpliconSequencing/4-BetaDiversity/3-NMDS/
cp -r R_output/*PLSDA* ./Result_AmpliconSequencing/4-BetaDiversity/4-PLS-DA/
cp -r R_output/*PCA* ./Result_AmpliconSequencing/4-BetaDiversity/6-PCA/
#cp -r core-metrics-results/weighted*significance.qzv* ./Result_AmpliconSequencing/4-BetaDiversity/5-GroupSignificance/
cp -r exported/feature-table.taxonomy.txt ./Result_AmpliconSequencing/2-AbundanceAnalysis/${category_1}_feature-table.taxonomy.txt
cp dna-sequences.fasta ./Result_AmpliconSequencing/2-AbundanceAnalysis/${category_1}_representative-sequence.fasta
cp tree.nwk ./Result_AmpliconSequencing/2-AbundanceAnalysis/${category_1}_rooted-tree.nwk
#cp -r R_output/Bacteria.phylogeny.pdf ./Result_AmpliconSequencing/5-Phylogenetics/1-MajorPhylums/
#cp -r phylogeny/tol_* phylogeny/tree.rooted.nwk ./Result_AmpliconSequencing/5-Phylogenetics/2-MajorOTUs/
#cp -r phylogeny/tol_* phylogeny/tree.rooted.nwk ./Result_AmpliconSequencing/5-Phylogenetics/
cp -r exported/Absolute/RDA/* ./Result_AmpliconSequencing/6-AssociationAnalysis/1-RDA/
#rm ./Result_AmpliconSequencing/6-AssociationAnalysis/1-RDA/*/data.txt ./Result_AmpliconSequencing/6-AssociationAnalysis/1-RDA/*/rda.R
#cp -r exported/Absolute/p.rda.pdf ./Result_AmpliconSequencing/6-AssociationAnalysis/1-RDA/Phylum.rda.pdf
#cp -r exported/Absolute/c.rda.pdf ./Result_AmpliconSequencing/6-AssociationAnalysis/1-RDA/Class.rda.pdf
#cp -r exported/Absolute/o.rda.pdf ./Result_AmpliconSequencing/6-AssociationAnalysis/1-RDA/Order.rda.pdf
#cp -r exported/Absolute/f.rda.pdf ./Result_AmpliconSequencing/6-AssociationAnalysis/1-RDA/Family.rda.pdf
#cp -r exported/Absolute/g.rda.pdf ./Result_AmpliconSequencing/6-AssociationAnalysis/1-RDA/Genus.rda.pdf
#cp -r exported/Absolute/s.rda.pdf ./Result_AmpliconSequencing/6-AssociationAnalysis/1-RDA/Species.rda.pdf
#cp -r /Result_AmpliconSequencing/6-AssociationAnalysis
cp AdditionalPhylogeny/*.pdf ./Result_AmpliconSequencing/5-Phylogenetics/
cp -rp 4-VennAndFlower/ ./Result_AmpliconSequencing/1-VennAndFlower
rm ./Result_AmpliconSequencing/1-VennAndFlower/*.log
cp -rp 3-NetworkAnalysis/ ./Result_AmpliconSequencing/6-AssociationAnalysis/
cp -rp 2-CorrelationHeatmap/ ./Result_AmpliconSequencing/6-AssociationAnalysis/
cp -rp alpha-rarefaction-ggplot2/ ./Result_AmpliconSequencing/3-AlphaDiversity/2-AlphaRarefaction/
cp -rp Barplot-of-Group-Mean/ ./Result_AmpliconSequencing/2-AbundanceAnalysis/1-AbundanceSummary/2-Barplots/taxa-bar-plots-top20-group-mean
cp -rp taxa-bar-plots-top20-group-ordered/ ./Result_AmpliconSequencing/2-AbundanceAnalysis/1-AbundanceSummary/2-Barplots/taxa-bar-plots-top20
#rm ./Result_AmpliconSequencing/2-AbundanceAnalysis/1-AbundanceSummary/2-Barplots/taxa-bar-plots-top20-group-mean/*svg
#change index.html to a more obvious name, and organize the qzv.exported and qzv files.
#cd ./Result_AmpliconSequencing/
for f in $(find ./Result_AmpliconSequencing/ -type f -name "*qzv"); do echo $f; base=$(basename $f .qzv); dir=$(dirname $f); mv $f ${f}.exported; mv ${f}.exported ${dir}/${base}; done
for f in $(find ./Result_AmpliconSequencing/ -type f -name "index.html") ; do echo $f; base=$(basename $f .html); dir=$(dirname $f); new=${dir}/Summary_请点此文件查看.html; mv $f $new; done
#cd ../
#minor adjustment of file structure
mv ./Result_AmpliconSequencing/2-AbundanceAnalysis/1-AbundanceSummary/2-Barplots/taxa-bar-plots/ ./Result_AmpliconSequencing/2-AbundanceAnalysis/1-AbundanceSummary/2-Barplots/taxa-bar-plots_Qiime2
mv ./Result_AmpliconSequencing/3-AlphaDiversity/2-AlphaRarefaction/alpha-rarefaction ./Result_AmpliconSequencing/3-AlphaDiversity/2-AlphaRarefaction/alpha-rarefaction-Qiime2
rm -r ./Result_AmpliconSequencing/4-BetaDiversity/2-PCoA/PCoA-Qiime2/jaccard_emperor
###rename the pcoa results
#mv ./Result_AmpliconSequencing/4-BetaDiversity/*emperor* ./Result_AmpliconSequencing/4-BetaDiversity/2-PCoA/1-Plots-from-QIIME2
#mv ./Result_AmpliconSequencing/4-BetaDiversity/*PCoA* ./Result_AmpliconSequencing/4-BetaDiversity/2-PCoA/2-Plots-from-R
#######################For 7-FiguresTablesForReport
cp -rp ${SCRIPTPATH}/Report_others/src Result_AmpliconSequencing/7-FiguresTablesForReport/
cp ${SCRIPTPATH}/Report_others/结题报告.html Result_AmpliconSequencing/
cd ./Result_AmpliconSequencing/7-FiguresTablesForReport
cp -rp ../2-AbundanceAnalysis/1-AbundanceSummary/3-Heatmaps/Heatmap-Qiime2/${category_1}-table-Phylum.${number}/ page4
cp -rp ../2-AbundanceAnalysis/2-AbundanceComparison/1-ANCOM/${category_1}.ANCOM.Genus/ page4-2
cp -rp ../4-BetaDiversity/5-GroupSignificance/unweighted_unifrac-permanova-${category_1}-significance/ page6-2
#cp ../1-QCStats/1-Stats-demux/demultiplex-summary.png Figure3-1.png
#cp ../2-AbundanceAnalysis/Classified_stat_relative.png Figure4-1.png
cp ../2-AbundanceAnalysis/1-AbundanceSummary/2-Barplots/taxa-bar-plots-top20-group-mean/${category_1}_Phylum_mean_barplot.pdf Figure4-2.pdf
cp ../2-AbundanceAnalysis/2-AbundanceComparison/4-LEfSe/Genus/${category_1}_Genus_lefse_LDA2.pdf Figure4-3.pdf
cp ../2-AbundanceAnalysis/2-AbundanceComparison/4-LEfSe/Genus/${category_1}_Genus_lefse_LDA2.cladogram.pdf Figure4-4.pdf
cp ../1-VennAndFlower/${category_1}_Venn_plot.png Figure4-5.png
cp ../3-AlphaDiversity/1-AlphaDiversitySummary/${category_1}_alpha_diversity_shannon.boxplot.pdf Figure5-1.pdf
cp ../3-AlphaDiversity/3-SignificanceAnalysis/1-Wilcox_Test/shannon_${category_1}_wilcox_compare_boxplot.png Figure5-2.png
cp ../4-BetaDiversity/1-BetaDiversitySummary/BetaDiversity_heatmap.png Figure6-1.png
cp ../4-BetaDiversity/3-NMDS/${category_1}_unweighted_unifrac_NMDS_without_labels.pdf Figure6-2.pdf
cp ../5-Phylogenetics/${category_1}_phylogenetic_tree_heatmap.pdf Figure7-1.pdf
cp ../6-AssociationAnalysis/1-RDA/Genus/${category_1}*bacteria_location_plot.pdf Figure8-1.pdf
cp ../6-AssociationAnalysis/2-CorrelationHeatmap/Genus/Correlation_heatmap.pdf Figure8-2.pdf
cp ../6-AssociationAnalysis/3-NetworkAnalysis/Genus/Correlation_network.pdf Figure8-3.pdf
if [ -f Figure4-2.pdf ];then echo "Converting pdf to png"; for pdfs in *.pdf; do echo $pdfs; base=$(basename $pdfs .pdf); convert -density 300 -quality 80 $pdfs ${base}.png; rm $pdfs;done;fi;
python ~/github/Bayegy/convert_to_html_table.py -i ../../../Result_AmpliconSequencing/1-OTUStats/2-Stats-dada2/Summary_请点此文件查看.html -o src/pages/main_cleaned.html -t dada2html -k '无法加载表格表3-1'