Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
umrf
ranomaly
Commits
8df5bf32
Commit
8df5bf32
authored
Jul 26, 2021
by
Etienne Rifa
Browse files
csv2phyloseq update
parent
d86f9139
Changes
2
Hide whitespace changes
Inline
Side-by-side
R/csv2phyloseq_fun.R
View file @
8df5bf32
#' Create Phyloseq object from external datas.
#'
#'
#' @param otutable
T
abulated ASVtable
file path
.
#' @param taxtable
T
abulated taxonomy table
file path
.
#' @param
seq Tabulated sequence file path
.
#' @param metadata
T
abulated metadata
file path
.
#' @param otutable
Path to the t
abulated ASV
/OTU
table
or data.frame object
.
#' @param taxtable
Path to the t
abulated taxonomy table
or data.frame object
.
#' @param
Path to sequence in fasta format or DNAStringSet object
.
#' @param metadata
Path to the t
abulated metadata
table or data.frame object
.
#' @param generateTree Boolean to generate the phylogenetic tree.
#' @param output Output directory
#' @param returnval Boolean to return values in console or not.
...
...
@@ -19,18 +19,41 @@ csv2phyloseq_fun <- function(otutable = NULL, taxtable = NULL, seq = NULL, metad
flog.info
(
"Input..."
)
flog.info
(
"...OTUtable..."
)
otable
<-
read.table
(
otutable
,
sep
=
"\t"
,
h
=
TRUE
)
row.names
(
otable
)
=
otable
[,
1
]
if
(
is.data.frame
(
otutable
)){
otable
<-
otutable
}
else
{
otable
<-
read.table
(
otutable
,
sep
=
"\t"
,
h
=
TRUE
,
check.names
=
FALSE
)
row.names
(
otable
)
=
otable
[,
1
]
otable
=
otable
[,
-1
]
}
flog.info
(
"...TAXtable..."
)
ttable
<-
as.matrix
(
read.table
(
taxtable
,
sep
=
"\t"
,
h
=
TRUE
,
stringsAsFactors
=
FALSE
))
row.names
(
ttable
)
=
ttable
[,
1
]
if
(
is.data.frame
(
taxtable
)){
print
(
"dF"
)
head
(
taxtable
)
ttable
<-
taxtable
}
else
{
ttable
<-
as.matrix
(
read.table
(
taxtable
,
sep
=
"\t"
,
h
=
TRUE
,
stringsAsFactors
=
FALSE
))
row.names
(
ttable
)
=
ttable
[,
1
]
# first columns is otu ids.
ttable
=
ttable
[,
-1
]
}
flog.info
(
"...Metadatas..."
)
mtable
<-
read.table
(
metadata
,
sep
=
"\t"
,
h
=
TRUE
)
if
(
is.data.frame
(
metadata
)){
mtable
<-
metadata
}
else
{
mtable
<-
read.table
(
metadata
,
sep
=
"\t"
,
h
=
TRUE
)
}
row.names
(
mtable
)
=
mtable
[,
1
]
flog.info
(
"...Sequences..."
)
stable
<-
read.table
(
seq
,
sep
=
"\t"
,
h
=
TRUE
)
sequences1
=
DNAStringSet
(
stable
[,
-1
])
names
(
sequences1
)
=
stable
[,
1
]
if
(
class
(
seq
)
==
"DNAStringSet"
){
sequences1
=
seq
}
else
{
sequences1
<-
readDNAStringSet
(
seq
)
}
print
(
head
(
otable
))
print
(
head
(
ttable
))
print
(
head
(
mtable
))
print
(
head
(
sequences1
))
if
(
generateTree
){
...
...
@@ -53,9 +76,10 @@ csv2phyloseq_fun <- function(otutable = NULL, taxtable = NULL, seq = NULL, metad
flog.info
(
'Done.'
)
tree
<-
fitGTR
$
tree
data
<-
phyloseq
(
otu_table
(
otable
[,
-1
]
,
taxa_are_rows
=
TRUE
),
sample_data
(
mtable
),
tax_table
(
ttable
[,
-1
]
),
sequences1
,
tree
)
# phy_tree(tree),
data
<-
phyloseq
(
otu_table
(
otable
,
taxa_are_rows
=
TRUE
),
sample_data
(
mtable
),
tax_table
(
ttable
),
sequences1
,
tree
)
# phy_tree(tree),
}
else
{
data
<-
phyloseq
(
otu_table
(
otable
[,
-1
],
taxa_are_rows
=
TRUE
),
sample_data
(
mtable
),
tax_table
(
ttable
[,
-1
]),
sequences1
)
flog.info
(
'Phyloseq object...'
)
data
<-
phyloseq
(
otu_table
(
otable
,
taxa_are_rows
=
TRUE
),
sample_data
(
mtable
),
tax_table
(
as.matrix
(
ttable
)),
sequences1
)
}
if
(
!
dir.exists
(
output
)){
...
...
man/csv2phyloseq_fun.Rd
View file @
8df5bf32
...
...
@@ -15,19 +15,19 @@ csv2phyloseq_fun(
)
}
\arguments{
\item{otutable}{
T
abulated ASVtable
file path
.}
\item{otutable}{
Path to the t
abulated ASV
/OTU
table
or data.frame object
.}
\item{taxtable}{
T
abulated taxonomy table
file path
.}
\item{taxtable}{
Path to the t
abulated taxonomy table
or data.frame object
.}
\item{seq}{Tabulated sequence file path.}
\item{metadata}{Tabulated metadata file path.}
\item{metadata}{Path to the tabulated metadata table or data.frame object.}
\item{generateTree}{Boolean to generate the phylogenetic tree.}
\item{output}{Output directory}
\item{returnval}{Boolean to return values in console or not.}
\item{Path}{to sequence in fasta format or DNAStringSet object.}
}
\value{
Return a phyloseq object
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment