-
Notifications
You must be signed in to change notification settings - Fork 0
/
LULU_prep.R
36 lines (31 loc) · 1.2 KB
/
LULU_prep.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
# load libraries --------------
library(openssl)
# Functions ------------------------------------
extrSamDADA2 <- function(my_table) {
out_path <- file.path(getwd(), "DADA2_extracted_samples")
if(!file_test("-d", out_path)) dir.create(out_path)
for (sampleX in seq(1:dim(my_table)[1])){
sinkname <- file.path(out_path, paste0(rownames(my_table)[sampleX],".fas"))
{
sink(sinkname)
for (seqX in seq(1:dim(my_table)[2])) {
if (my_table[sampleX,seqX] > 0) {
header <- paste0(">",openssl::sha1(colnames(my_table)[seqX]),";size=",
my_table[sampleX,seqX],";barcodelabel=",rownames(my_table)[sampleX],";","\n")
cat(header)
seqq <- paste0(colnames(my_table)[seqX],"\n")
cat(seqq)
}
}
sink()
}
}
}
# generate tab-delimited OTU table with taxa as rows
DADA2_otutab <- readRDS("seqtab_final_original.rds")
LULU_DADA2_otutab <- t(DADA2_otutab)
#rownames should already be SHA1 sums
#print(rownames(LULU_DADA2_otutab)[1:5])
#rownames(LULU_DADA2_otutab) <- sha1(rownames(LULU_DADA2_otutab))
#write.table(LULU_DADA2_otutab, file = "DADA2_sha1_otutab.tsv", sep = "\t", quote = FALSE)
extrSamDADA2(DADA2_otutab)