-
Notifications
You must be signed in to change notification settings - Fork 0
/
00_Parse_ITSand16S.R
executable file
·65 lines (45 loc) · 1.67 KB
/
00_Parse_ITSand16S.R
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
#### Indigo Ag Maize Microbiome Project
#### Corey Schultz - UGA - Wallace Lab
#
### Script to parse apart fungal and bacteria sequences
library(dplyr)
getwd()
setwd("//wsl.localhost/Ubuntu-18.04/home/crschul/IndigoAgMicrobiome")
list.dirs()
fastqs <- list.files("Indigo_RawData/g2f_indigo_combined")
crude <- read.csv("MetaData_Stuff/Crude_16s_vs_ITS.csv")
# assign samples bacteria or fungus
crude['assign'] <- NA
for(r in 1:nrow(crude)){
bact <- crude[r,"crude_16s"]
fung <- crude[r,"crude_its"]
if(bact > fung){
crude[r,"assign"] = "bact"
} else {
crude[r,"assign"] = "fung"
}
}
# divide fastqs based on that assignment
bacts <- filter(crude, assign == "bact")
fungs <- filter(crude, assign == "fung")
# sort bacteria
bfiles <- list()
for(r in 1:nrow(bacts)){
tstring <- bacts[r,1]
bfiles <- append(bfiles,fastqs[grep(tstring,fastqs)])
}
move_bact <- function(x){
file.rename(from = file.path("\\\\wsl.localhost/Ubuntu-18.04/home/crschul/IndigoAgMicrobiome/Indigo_RawData/g2f_indigo_combined", x) ,
to = file.path("\\\\wsl.localhost/Ubuntu-18.04/home/crschul/IndigoAgMicrobiome/Indigo_RawData/Bacteria_Sequences", x))
}
# sort fungus
ffiles <- list()
for(r in 1:nrow(fungs)){
tstring <- fungs[r,1]
ffiles <- append(ffiles,fastqs[grep(tstring,fastqs)])
}
move_fung <- function(x){
file.rename(from = file.path("\\\\wsl.localhost/Ubuntu-18.04/home/crschul/IndigoAgMicrobiome/Indigo_RawData/g2f_indigo_combined", x) ,
to = file.path("\\\\wsl.localhost/Ubuntu-18.04/home/crschul/IndigoAgMicrobiome/Indigo_RawData/Fungal_Sequences", x))
}
lapply(ffiles, move_fung)