diff --git a/DESCRIPTION b/DESCRIPTION index f0601f5..45752e9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: vite Type: Package Title: Analyzing single-cell data using graphs -Version: 0.4.7 +Version: 0.4.8 Authors@R: "Pier Federico Gherardini [aut, cre]" Description: This is a package for visualization and analysis of high-dimensional single-cell data using graphs @@ -13,4 +13,4 @@ LinkingTo: Rcpp License: GPL v3 Encoding: UTF-8 LazyData: true -RoxygenNote: 6.1.0 +RoxygenNote: 7.1.1 diff --git a/NAMESPACE b/NAMESPACE index 4bf6050..ec75c80 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,6 +2,8 @@ export(build_graph) export(complete_forceatlas2) +export(cosine_similarity_from_matrix) +export(cosine_similarity_matrix) export(filter_matrix_by_rank) export(get_scaffold_map) export(get_unsupervised_graph) diff --git a/R/unsupervised.R b/R/unsupervised.R index f8b7ae7..7f9d23e 100644 --- a/R/unsupervised.R +++ b/R/unsupervised.R @@ -6,6 +6,7 @@ #' @return Returns a vector of length \code{N} containing the cosine similarity between #' the vector \code{x} and all the rows of \code{m} #' +#' @export cosine_similarity_from_matrix <- function(x, m) { x <- x / as.vector(sqrt(crossprod(x))) return(as.vector((m %*% x) / sqrt(rowSums(m^2)))) @@ -21,6 +22,8 @@ cosine_similarity_from_matrix <- function(x, m) { #' #' @return Returns an \code{N x N} matrix with the cosine similarity between the corresponding rows in \code{m} #' +#' +#' @export cosine_similarity_matrix <- function(m){ ret <- m %*% t(m) / (sqrt(rowSums(m^2) %*% t(rowSums(m^2)))) return(ret) diff --git a/man/add_vertices_to_landmarks_graph.Rd b/man/add_vertices_to_landmarks_graph.Rd index 2416c6e..7347175 100644 --- a/man/add_vertices_to_landmarks_graph.Rd +++ b/man/add_vertices_to_landmarks_graph.Rd @@ -4,8 +4,13 @@ \alias{add_vertices_to_landmarks_graph} \title{Add cluster vertices to a landmark graph} \usage{ -add_vertices_to_landmarks_graph(G, tab.clustered, tab.landmarks, col.names, - min.similarity = 0.5) +add_vertices_to_landmarks_graph( + G, + tab.clustered, + tab.landmarks, + col.names, + min.similarity = 0.5 +) } \arguments{ \item{G}{An \code{igraph} object representing the landmark graph} diff --git a/man/complete_forceatlas2.Rd b/man/complete_forceatlas2.Rd index 809f855..ad9ec79 100644 --- a/man/complete_forceatlas2.Rd +++ b/man/complete_forceatlas2.Rd @@ -4,8 +4,13 @@ \alias{complete_forceatlas2} \title{Performs a Complete cycle of ForceAtlas2} \usage{ -complete_forceatlas2(G, first.iter = 1000, overlap.method = NULL, - overlap.iter = NULL, ...) +complete_forceatlas2( + G, + first.iter = 1000, + overlap.method = NULL, + overlap.iter = NULL, + ... +) } \arguments{ \item{G}{The input graph} diff --git a/man/get_distances_from_landmarks.Rd b/man/get_distances_from_landmarks.Rd index 3db4b7d..92da965 100644 --- a/man/get_distances_from_landmarks.Rd +++ b/man/get_distances_from_landmarks.Rd @@ -4,8 +4,7 @@ \alias{get_distances_from_landmarks} \title{Calculate (and filter) disatances between cluster and landmark ondes} \usage{ -get_distances_from_landmarks(m, tab, col.names, q.thresh, - min.similarity = 0.5) +get_distances_from_landmarks(m, tab, col.names, q.thresh, min.similarity = 0.5) } \arguments{ \item{m}{A \code{data.frame} containing expression values for the cluster nodes} diff --git a/man/get_scaffold_map.Rd b/man/get_scaffold_map.Rd index eaa5412..ec9f73e 100644 --- a/man/get_scaffold_map.Rd +++ b/man/get_scaffold_map.Rd @@ -4,10 +4,17 @@ \alias{get_scaffold_map} \title{Creates a Scaffold map} \usage{ -get_scaffold_map(tab.clustered, col.names, tab.landmarks, - G.landmarks = NULL, ew.influence = ceiling(length(col.names)/3), - min.similarity = 0.5, inter.cluster.col.names = col.names, - inter.cluster.weight.factor = 0.7, overlap.method = "repel") +get_scaffold_map( + tab.clustered, + col.names, + tab.landmarks, + G.landmarks = NULL, + ew.influence = ceiling(length(col.names)/3), + min.similarity = 0.5, + inter.cluster.col.names = col.names, + inter.cluster.weight.factor = 0.7, + overlap.method = "repel" +) } \arguments{ \item{tab.clustered}{A \code{data.frame} containing the clusters to be represented in the Scaffold map. Each diff --git a/man/get_unsupervised_graph_from_files.Rd b/man/get_unsupervised_graph_from_files.Rd index 5f2f926..0b5d77e 100644 --- a/man/get_unsupervised_graph_from_files.Rd +++ b/man/get_unsupervised_graph_from_files.Rd @@ -4,11 +4,17 @@ \alias{get_unsupervised_graph_from_files} \title{Builds an unsupervised graph starting from a list of input files} \usage{ -get_unsupervised_graph_from_files(files.list, col.names, - filtering.threshold, metadata.tab = NULL, - metadata.filename.col = NULL, use.basename = TRUE, - process.clusters.data = TRUE, clusters.data.out.dir = "./", - downsample.to = 1000) +get_unsupervised_graph_from_files( + files.list, + col.names, + filtering.threshold, + metadata.tab = NULL, + metadata.filename.col = NULL, + use.basename = TRUE, + process.clusters.data = TRUE, + clusters.data.out.dir = "./", + downsample.to = 1000 +) } \arguments{ \item{files.list}{The list of files to process. The function will first determine the set of columns that are common to all diff --git a/man/layout_forceatlas2.Rd b/man/layout_forceatlas2.Rd index ac4a402..3bc4ab1 100644 --- a/man/layout_forceatlas2.Rd +++ b/man/layout_forceatlas2.Rd @@ -4,9 +4,16 @@ \alias{layout_forceatlas2} \title{ForceAtlas2 force-directed layout} \usage{ -layout_forceatlas2(G, ew.influence = 1, kgrav = 1, iter = 1000, - prevent.overlap = FALSE, fixed = NULL, stopping.tolerance = 0.001, - barnes.hut = FALSE) +layout_forceatlas2( + G, + ew.influence = 1, + kgrav = 1, + iter = 1000, + prevent.overlap = FALSE, + fixed = NULL, + stopping.tolerance = 0.001, + barnes.hut = FALSE +) } \arguments{ \item{G}{The input \code{igraph} object. The graph must have an edge attribute named \code{weight}, representing edge weights} diff --git a/man/load_landmarks_from_dir.Rd b/man/load_landmarks_from_dir.Rd index 0f3c47c..27bc71c 100644 --- a/man/load_landmarks_from_dir.Rd +++ b/man/load_landmarks_from_dir.Rd @@ -9,11 +9,12 @@ load_landmarks_from_dir(dir, ...) \arguments{ \item{dir}{A directory name. All the FCS files in the directory will be loaded} -\item{...}{Arguments passed on to \code{load_landmarks} -\describe{ - \item{asinh.cofactor}{The cofactor to use for \code{asinh} transformation. If this is \code{NULL} no transformation +\item{...}{ + Arguments passed on to \code{\link[=load_landmarks]{load_landmarks}} + \describe{ + \item{\code{asinh.cofactor}}{The cofactor to use for \code{asinh} transformation. If this is \code{NULL} no transformation is applied} -}} + }} } \value{ Returns a list with the following elements: diff --git a/man/run_scaffold_analysis.Rd b/man/run_scaffold_analysis.Rd index a591a2f..075c917 100644 --- a/man/run_scaffold_analysis.Rd +++ b/man/run_scaffold_analysis.Rd @@ -4,9 +4,16 @@ \alias{run_scaffold_analysis} \title{High level wrapper for performing a Scaffold analysis} \usage{ -run_scaffold_analysis(files.list, ref.file, landmarks.data, col.names, - out.dir = "scaffold_result", process.clusters.data = TRUE, - downsample.to = 1000, ...) +run_scaffold_analysis( + files.list, + ref.file, + landmarks.data, + col.names, + out.dir = "scaffold_result", + process.clusters.data = TRUE, + downsample.to = 1000, + ... +) } \arguments{ \item{files.list}{Character vector. The list of files to process} diff --git a/man/write_clusters_data.Rd b/man/write_clusters_data.Rd index 67bccfd..de71b92 100644 --- a/man/write_clusters_data.Rd +++ b/man/write_clusters_data.Rd @@ -4,8 +4,12 @@ \alias{write_clusters_data} \title{Write clustering output} \usage{ -write_clusters_data(clustered.data, base.name, output.dir = "./", - pooled.only = FALSE) +write_clusters_data( + clustered.data, + base.name, + output.dir = "./", + pooled.only = FALSE +) } \arguments{ \item{clustered.data}{A \code{data.frame} containing the clustered data. Each row corresponds to cell. The \code{data.frame} diff --git a/man/write_scaffold_output.Rd b/man/write_scaffold_output.Rd index 681fd14..2dc968c 100644 --- a/man/write_scaffold_output.Rd +++ b/man/write_scaffold_output.Rd @@ -4,8 +4,14 @@ \alias{write_scaffold_output} \title{Write the result of a Scaffold analysis} \usage{ -write_scaffold_output(G, out.dir, out.name, clusters.data = NULL, - landmarks.data = NULL, downsample.to = 1000) +write_scaffold_output( + G, + out.dir, + out.name, + clusters.data = NULL, + landmarks.data = NULL, + downsample.to = 1000 +) } \arguments{ \item{G}{An \code{igraph} object representing the Scaffold map}