Skip to content

Commit

Permalink
setTree
Browse files Browse the repository at this point in the history
  • Loading branch information
noriakis committed Oct 25, 2023
1 parent ae8846d commit b4ee6df
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 4 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export(plotKEGGPathway)
export(plotPCA)
export(plotTree)
export(setAnnotation)
export(setTree)
export(strainClusterHeatmap)
export(summariseAbundance)
import(BiocFileCache)
Expand Down
11 changes: 7 additions & 4 deletions R/plotCirclize.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#' @param returnRawDf return the raw data frame used in the plot
#' @param featCircos which type of circos to use in the corresponding feature
#' @param include_gene include these gene IDs, ignoring the thesh_snp_gene argument
#' @param only_genome_id show only the genome IDs
#' @importFrom circlize CELL_META circos.clear circos.par circos.initialize circos.rect circos.barplot circos.track circos.text circos.points
#' @return draw circlize plot
#' @export
Expand All @@ -30,7 +31,7 @@ plotCirclize <- function(stana, candSp, genomeId, include_gene=NULL,
cols=c("tomato","steelblue","gold","seagreen"),
controlColor="steelblue", MAF=FALSE, cl=NULL,
featCircos=list(), showGeneName=TRUE,
returnRawDf=FALSE,
returnRawDf=FALSE, only_genome_id=FALSE,
featThresh=0, cex=0.3, textCex=0.5,bar_width=10,
contPalette=c("steelblue",
"tomato"), discPalette="Dark2") {
Expand Down Expand Up @@ -76,16 +77,18 @@ plotCirclize <- function(stana, candSp, genomeId, include_gene=NULL,
qqcat("Genome ID in SNV information:\n")
for (i in unique(info$genome_id)) {
tmp_info <- subset(info, genome_id==i)
qqcat(" @{i}: @{min(tmp_info$position)} - @{max(tmp_info$position)}, number of position: @{nrow(tmp_info)}\n")
qqcat(" @{i}: @{min(tmp_info$position)} - @{max(tmp_info$position)}",
", number of position: @{nrow(tmp_info)}\n")
}

if (only_genome_id) {return(1)}

qqcat("Genome ID: @{genomeId}\n")

## Deleting "None" and gene ids with only one position
info$genome_id <- info$genome_id |> strsplit("_") |>
vapply("[", 1, FUN.VALUE="character")
circ_plot <- subset(info, info$genome_id==genomeId)

if (length(featList)>0) {
for (nm in names(featList)) {
circ_plot[[nm]] <- featList[[nm]][row.names(circ_plot)]
Expand All @@ -99,9 +102,9 @@ plotCirclize <- function(stana, candSp, genomeId, include_gene=NULL,
circ_plot <- subset(circ_plot, !circ_plot$gene_id %in% names(gene_num[gene_num<thresh_snp_gene]))
} else {
circ_plot <- subset(circ_plot, circ_plot$gene_id %in% include_gene)

}
qqcat("Included position: @{dim(circ_plot)[1]}\n")
if (dim(circ_plot)[1]==0) {stop("No position available, finishing ...")}
if (returnRawDf) {return(circ_plot)}
circos.clear() ## If have one
circos.par(cell.padding=c(0.02,0,0.02,0),
Expand Down
12 changes: 12 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,16 @@
cnDiscretize <- function(stana, species, cutoff=0.35) {
df <- stana@genes[["100224"]]
apply(df, 2, function(x) ifelse(x>cutoff, 1, 0)) |> data.frame()
}

#' setTree
#' @param stana stana object
#' @param species species ID
#' @param tre tree to be set
#' @export
#' @return stana
setTree <- function(stana, species, tre) {
if (class(tre)!="phylo") {stop("Please provide phylo object")}
stana@treeList[[species]] <- tre
return(stana)
}
3 changes: 3 additions & 0 deletions man/plotCirclize.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions man/setTree.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b4ee6df

Please sign in to comment.