Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
43 changes: 16 additions & 27 deletions R/KNN.graph.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
#' @param knn.outlier.th
#' @param outlier.frac.th
#'
#' @return
#' @return value.
#' @export
#'
#' @examples

get_knn_graph <- function(rd.dat, cl, ref.cells=row.names(rd.dat),method="Annoy.Cosine", k=15, knn.outlier.th=2, outlier.frac.th=0.5,clean.cells=row.names(rd.dat), knn.result=NULL,mc.cores=10)
{
if(is.null(knn.result)){
Expand Down Expand Up @@ -78,9 +77,6 @@ get_knn_graph <- function(rd.dat, cl, ref.cells=row.names(rd.dat),method="Annoy.
#' @param bg.alpha alpha to use for edges that are more faint. Default = 0.1
#' @param coord_fixed Cartesian coordinates with fixed "aspect ratio". See ggplot::coord_fixed. Default is TRUE
#'
#'
#' @example_data:
#'
#' knn.cl.df <- read.csv("data/Constellation_example/knn.cl.df.csv")
#' cl.center.df <- read.csv("data/Constellation_example/cl.center.df.csv", row.names=1)
#'
Expand Down Expand Up @@ -747,10 +743,9 @@ plot_constellation <- function (knn.cl.df,
#' @param line.segments
#' @param curved
#'
#' @return
#' @return value.
#' @export
#'
#' @examples

edgeMaker <- function(whichRow, len=100, line.segments, curved=FALSE){

fromC <- unlist(line.segments[whichRow,c(3,4)])# Origin
Expand Down Expand Up @@ -788,10 +783,9 @@ edgeMaker <- function(whichRow, len=100, line.segments, curved=FALSE){
#' @param y
#' @param len
#'
#' @return
#' @return value.
#' @export
#'
#' @examples

perpStart <- function(x, y, len) {
perp(x, y, len, angle(x, y), 1)
}
Expand All @@ -801,10 +795,9 @@ perpStart <- function(x, y, len) {
#' @param x
#' @param y
#'
#' @return
#' @return value.
#' @export
#'
#' @examples

avgangle <- function(x, y) {
a1 <- angle(x[1:2], y[1:2])
a2 <- angle(x[2:3], y[2:3])
Expand All @@ -819,10 +812,9 @@ avgangle <- function(x, y) {
#' @param a
#' @param mid
#'
#' @return
#' @return value.
#' @export
#'
#' @examples

perp <- function(x, y, len, a, mid) {
dx <- len*cos(a + pi/2)
dy <- len*sin(a + pi/2)
Expand All @@ -837,10 +829,9 @@ perp <- function(x, y, len, a, mid) {
#' @param y
#' @param len
#'
#' @return
#' @return value.
#' @export
#'
#' @examples

perpMid <- function(x, y, len) {
## Now determine angle at midpoint
perp(x, y, len, avgangle(x, y), 2)
Expand All @@ -852,10 +843,9 @@ perpMid <- function(x, y, len) {
#' @param y
#' @param len
#'
#' @return
#' @return value.
#' @export
#'
#' @examples

perpEnd <- function(x, y, len) {
perp(x, y, len, angle(x, y), 2)
}
Expand All @@ -867,10 +857,9 @@ perpEnd <- function(x, y, len) {
#' @param x vector
#' @param y vector
#'
#' @return
#' @return value.
#' @export
#'
#' @examples

angle <- function(x, y) {
atan2(y[2] - y[1], x[2] - x[1])
}
Expand Down
3 changes: 0 additions & 3 deletions R/annotate.R
Original file line number Diff line number Diff line change
Expand Up @@ -524,11 +524,8 @@ compare_annotate <- function(cl,
#' @return a character vector of hex colors with duplicated colors replaced
#'
#' @export
#'
#' @examples
#'
#' original_colors <- c("#00FF00","#00FF00","#FF0000","#00FF00")
#'
#' new_colors <- adjust_color(original_colors)
#'
adjust_color <- function(colorset) {
Expand Down
4 changes: 2 additions & 2 deletions R/big_util.R
Original file line number Diff line number Diff line change
Expand Up @@ -429,12 +429,12 @@ convert_h5ad_big.dat_parquet <- function(fn, adata=NULL, dir=getwd(),parquet.dir
##' .. content for \description{} (no empty lines) ..
##'
##' .. content for \details{} ..
##' @title
##' @title append_big.dat_parquet
##' @param mat
##' @param big.dat
##' @param col.bin.size
##' @param row.bin.size
##' @return
##' @return value
##' @author Zizhen Yao
append_big.dat_parquet <- function(mat, big.dat, col.bin.size=50000, row.bin.size=500, mc.cores=10)
{
Expand Down
2 changes: 1 addition & 1 deletion R/consensusCluster.R
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ compile_cl_mat <- function(cl.list, select.cells)
#' @param niter maxmimal mumber of refinement iterations.
#' @param tol.th If improvement is smaller than this threshold, terminate refinement step.
#' @param verbose If true, print out step-by-step improvement.
#' @return
#' @return value
#' @author Zizhen Yao
refine_cl <- function(cl,
co.ratio=NULL,
Expand Down
32 changes: 12 additions & 20 deletions R/de.genes.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
#' \code{min.genes} is the minimum number of differentially expressed genes (passing the \code{padj.th} and \code{lfc.th} thresholds, above)
#' required to consider two clusters separate.
#'
#' @return returns a list of parameters for reuse
#' @return value. returns a list of parameters for reuse
#' @export
#'
#' @examples
Expand Down Expand Up @@ -202,7 +202,7 @@ de_param <- function(low.th = 1,
#' @param y an integer vector with the number of cells in group \emph{y} with detection of each gene.
#' @param y.total an integer value with the total number of cells in group \emph{y}.
#'
#' @return a data.frame with the following result for each gene:
#' @return value. a data.frame with the following result for each gene:
#' \itemize{
#' \item{stats: The value of the chi-squared test statistic}
#' \item{pval: The p-value as reported by pchisq}
Expand Down Expand Up @@ -252,7 +252,7 @@ vec_chisq_test <- function(x,
#' @param fit a limma fit object
#' @param genes the genes to use for pairwise comparisons
#'
#' @return a data.frame with DE statistics:
#' @return value. a data.frame with DE statistics:
#' \itemize{
#' \item{padj} P-values adjusted using the Holm (1979) method (\code{p.adjust()} default).
#' \item{pval} P-values reported by the \code{limma::eBayes()} function.
Expand Down Expand Up @@ -317,7 +317,7 @@ de_pair_limma <- function(pair,
#' @param cl.size a named numeric vector of cluster sizes
#' @param genes the genes to use for pairwise comparisons
#'
#' @return a data.frame with DE statistics:
#' @return value. a data.frame with DE statistics:
#' \itemize{
#' \item{padj} P-values adjusted using the Holm (1979) method (\code{p.adjust()} default).
#' \item{pval} P-values reported by the \code{vec_chisq_test()} function.
Expand Down Expand Up @@ -366,7 +366,7 @@ de_pair_chisq <- function(pair,
#' @param cl.size a named numeric vector of cluster sizes
#' @param genes the genes to use for pairwise comparisons
#'
#' @return a data.frame with DE statistics:
#' @return value. a data.frame with DE statistics:
#' \itemize{
#' \item{padj} P-values adjusted using the Holm (1979) method (\code{p.adjust()} default).
#' \item{pval} P-values reported by the \code{vec_chisq_test()} function.
Expand Down Expand Up @@ -544,10 +544,8 @@ de_pair_fast_limma <- function(pair,
#' @param direction
#' @param include.self
#'
#' @return
#' @return value.
#' @export
#'
#' @examples
create_pairs <- function(cn1, cn2=cn1,direction="nondirectional", include.self = FALSE)
{
cn1=as.character(cn1)
Expand Down Expand Up @@ -592,7 +590,7 @@ get_de_truncate_score_sum <- function(gene.score, th=20)
#' @param cl.size1 Optional: The number of samples in the first/high cluster
#' @param cl.size2 Optional: The number of samples in the second/low cluster
#'
#' @results A list of filtered differential expression results containing:
#' @return A list of filtered differential expression results containing:
#' \itemize{
#' \item{score} The deScore value, equal to the sum of the -log10(p-values) of differentially expressed genes, with a cap of 20 per gene.
#' \item{up.score} The deScore value for up-regulated genes.
Expand Down Expand Up @@ -705,7 +703,7 @@ de_stats_pair <- function(df,
#' @param de.df Optional. Pre-computed results from \code{de_all_pairs()} or \code{de_selected_pairs}. Default = NULL.
#' @param ... Additional parameters passed to \code{de_selected_pairs()}
#'
#' @return a character vector of all differentially expressed genes.
#' @return value. a character vector of all differentially expressed genes.
#' @export
#'
de_all_pairs <- function(norm.dat,
Expand Down Expand Up @@ -752,7 +750,7 @@ de_all_pairs <- function(norm.dat,
#' @details When directed = TRUE and field = "num", the minimum value from up or down-regulated genes is returned for each pair. When field = "score", the
#' minimum deScore is returned.
#'
#' @return a matrix with clusters as rows and columns, and pairwise DE results as values.
#' @return value. a matrix with clusters as rows and columns, and pairwise DE results as values.
#' @export
#'
get_de_matrix <- function(de.genes,
Expand Down Expand Up @@ -801,10 +799,8 @@ get_de_matrix <- function(de.genes,
#' @param file
#' @param ...
#'
#' @return
#' @return value.
#' @export
#'
#' @examples
plot_de_num <- function(de.genes,
dend,
cl.label = NULL,
Expand Down Expand Up @@ -850,10 +846,8 @@ plot_de_num <- function(de.genes,
#' @param select.pair
#' @param cl.label
#'
#' @return
#' @return value.
#' @export
#'
#' @examples
plot_de_lfc_num <- function(de.genes,
top.n = 100,
select.pair = NULL,
Expand Down Expand Up @@ -967,10 +961,8 @@ plot_de_lfc_num <- function(de.genes,
#' @param cl.label
#' @param ...
#'
#' @return
#' @return value.
#' @export
#'
#' @examples
plot_pair_matrix <- function(pair.num, file, directed=FALSE, dend=NULL, col=jet.colors(100), cl.label=NULL,...)
{
pair.matrix <- convert_pair_matrix(pair.num, directed = directed)
Expand Down
Loading