Skip to content

Commit

Permalink
nothing
Browse files Browse the repository at this point in the history
  • Loading branch information
QingfeiPan committed Aug 27, 2024
1 parent 1baa77c commit 8e47308
Show file tree
Hide file tree
Showing 18 changed files with 123 additions and 81 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ License: Apache License (>= 2)
Encoding: UTF-8
LazyData: TRUE
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
Depends:
R (>= 4.0),
base (>= 4.2.2),
Expand Down
13 changes: 8 additions & 5 deletions R/differential_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ combinePvalVector <- function(pvals,
#'
#' @examples
#' ## to call this function
#' res <- compare2groups(input_eset = input_eset,
#' data(pbmc14k_expression.eset)
#' res <- compare2groups(input_eset = pbmc14k_expression.eset,
#' group_by = group_by,
#' g1 = g1_tmp,
#' g0 = g0_tmp,
Expand Down Expand Up @@ -203,25 +204,26 @@ compare2groups <- function(input_eset,
#' @export
#'
#' @examples
#' data(pbmc14k_expression.eset)
#' ## 1. To perform differential expression analysis in a 1-vs-rest manner for all groups in "clusterID" column
#' de_res <- getDE(input_eset = clustered.eset,
#' de_res <- getDE(input_eset = pbmc14k_expression.eset,
#' group_by = "clusterID",
#' use_method = "limma")
#'
#' ## 2. To perform differential expression analysis in a 1-vs-rest manner for one specific group in "clusterID" column
#' de_res <- getDE(input_eset = clustered.eset,
#' de_res <- getDE(input_eset = pbmc14k_expression.eset,
#' group_by = "clusterID",
#' g1 = c("1"),
#' use_method = "limma")
#'
#' ## 3. To perform differential expression analysis in a rest-vs-1 manner for one specific group in "clusterID" column
#' de_res <- getDE(input_eset = clustered.eset,
#' de_res <- getDE(input_eset = pbmc14k_expression.eset,
#' group_by = "clusterID",
#' g0 = c("1"),
#' use_method = "limma")
#'
#' ## 4. To perform differential expression analysis in a 1-vs-1 manner for groups in "clusterID" column
#' de_res <- getDE(input_eset = clustered.eset,
#' de_res <- getDE(input_eset = pbmc14k_expression.eset,
#' group_by = "clusterID",
#' g1 = c("1"),
#' g0 = c("3"),
Expand Down Expand Up @@ -306,6 +308,7 @@ getDE <- function(input_eset,
#' @export
#'
#' @examples
#' data(pbmc14k_expression.eset)
#' ## 1. To perform differential activity analysis in a 1-vs-rest manner for all groups in "clusterID" column
#' da_res <- getDA(input_eset = activity_clustered.eset,
#' group_by = "clusterID",
Expand Down
28 changes: 16 additions & 12 deletions R/network_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,16 @@ getDriverList <- function(species_type = "hg",
#' @export
#'
#' @examples
#' data(pbmc14k_expression.eset)
#' ## 1. The most commonly used command: pre-defined driver lists, automatic down-sampling, no metacell method
#' generateSJARACNeInput(input_eset = normalized.eset,
#' generateSJARACNeInput(input_eset = pbmc14k_expression.eset,
#' group_name = "cell_type",
#' sjaracne_dir = "./SJARACNe",
#' species_type = "hg",
#' driver_type = "TF_SIG")
#'
#' ## 2. to disable the downsampling
#' generateSJARACNeInput(input_eset = normalized.eset,
#' generateSJARACNeInput(input_eset = pbmc14k_expression.eset,
#' group_name = "cell_type",
#' sjaracne_dir = "./SJARACNe",
#' species_type = "hg",
Expand All @@ -98,20 +99,20 @@ getDriverList <- function(species_type = "hg",
#' ## 3. Use the customized driver list: (add TUBB4A is the gene of interest but currently not in the pre-defined driver list)
#'
#' # when the driver-to-add is known as a transcription factor
#' generateSJARACNeInput(input_eset = normalized.eset, group_name = "cell_type", sjaracne_dir = "./SJARACNe", species_type = "hg", driver_type = "TF_SIG",
#' generateSJARACNeInput(input_eset = pbmc14k_expression.eset, group_name = "cell_type", sjaracne_dir = "./SJARACNe", species_type = "hg", driver_type = "TF_SIG",
#' customDriver_TF = c(getDriverList(species_type = "hg", driver_type = "TF"), "TUBB4A"))
#'
#' # when the driver-to-add is known as a non-transcription factor
#' generateSJARACNeInput(input_eset = normalized.eset, group_name = "cell_type", sjaracne_dir = "./SJARACNe", species_type = "hg", driver_type = "TF_SIG",
#' generateSJARACNeInput(input_eset = pbmc14k_expression.eset, group_name = "cell_type", sjaracne_dir = "./SJARACNe", species_type = "hg", driver_type = "TF_SIG",
#' customDriver_SIG = c(getDriverList(species_type = "hg", driver_type = "SIG"), "TUBB4A"))
#'
#' # when it's ambiguous to tell if the driver-to-add is a transcriptional factor
#' generateSJARACNeInput(input_eset = normalized.eset, group_name = "cell_type", sjaracne_dir = "./SJARACNe", species_type = "hg", driver_type = "TF_SIG",
#' generateSJARACNeInput(input_eset = pbmc14k_expression.eset, group_name = "cell_type", sjaracne_dir = "./SJARACNe", species_type = "hg", driver_type = "TF_SIG",
#' customDriver_TF = c(getDriverList(species_type = "hg", driver_type = "TF"), "TUBB4A"),
#' customDriver_SIG = c(getDriverList(species_type = "hg", driver_type = "SIG"), "TUBB4A"))
#'
#' ## 4. Use the metacell method
#' generateSJARACNeInput(input_eset = normalized.eset, group_name = "cell_type", sjaracne_dir = "./SJARACNe", species_type = "hg", driver_type = "TF_SIG",
#' generateSJARACNeInput(input_eset = pbmc14k_expression.eset, group_name = "cell_type", sjaracne_dir = "./SJARACNe", species_type = "hg", driver_type = "TF_SIG",
#' superCell_N = 1000, superCell_count = 100, seed = 123)
generateSJARACNeInput <- function(input_eset,
group_name = "clusterID",
Expand Down Expand Up @@ -762,7 +763,8 @@ cal_Activity <- function(target_list = NULL, cal_mat = NULL, activity_method = '
#' @export
#'
#' @examples
#' activity_group.eset <- getActivity_individual(input_eset = group_specific.est,
#' data(pbmc14k_expression.eset)
#' activity_group.eset <- getActivity_individual(input_eset = pbmc14k_expression.eset,
#' network_file.tf = "consensus_network_ncol_.txt",
#' network_file.sig = "consensus_network_ncol_.txt",
#' driver_type = "TF_SIG")
Expand Down Expand Up @@ -860,16 +862,18 @@ getActivity_individual <- function(input_eset,
#' @export
#'
#' @examples
#' data(pbmc14k_expression.eset)
#'
#' ## 1. when no tag was used in runing SJARACNE: the network file folder ("sjaracne_workflow-*") is directly under TF/SIG folder of each group.
#' activity.eset <- getActivity_inBatch(input_eset = normalized.eset,
#' activity.eset <- getActivity_inBatch(input_eset = pbmc14k_expression.eset,
#' sjaracne_dir = "./SJARACNe",
#' group_name = "cell_type",
#' driver_type = "TF_SIG",
#' activity_method = "mean",
#' do.z_normalization = TRUE)
#'
#' ## 2. when tag (e.g. "bs_100" ) was used: the nework file folder ("sjaracne_workflow-*") is directly under a subfolder "bs_100" of the TF/SIG folder of each group.
#' activity.eset <- getActivity_inBatch(input_eset = normalized.eset,
#' activity.eset <- getActivity_inBatch(input_eset = pbmc14k_expression.eset,
#' sjaracne_dir = "./SJARACNe",
#' group_name = "cell_type",
#' network_tag.tf = "bs_100",
Expand All @@ -879,7 +883,7 @@ getActivity_individual <- function(input_eset,
#' do.z_normalization = TRUE)
#'
#' ## 3. to calculate the activities of TF only
#' activity.eset <- getActivity_inBatch(input_eset = normalized.eset,
#' activity.eset <- getActivity_inBatch(input_eset = pbmc14k_expression.eset,
#' sjaracne_dir = "./SJARACNe",
#' group_name = "cell_type",
#' network_tag.tf = "bs_100",
Expand All @@ -889,7 +893,7 @@ getActivity_individual <- function(input_eset,
#' do.z_normalization = TRUE)
#'
#' ## 4. to exclude some groups in the activity calculation (e.g. "NK" and "Monocyte")
#' activity.eset <- getActivity_inBatch(input_eset = normalized.eset,
#' activity.eset <- getActivity_inBatch(input_eset = pbmc14k_expression.eset,
#' sjaracne_dir = "./SJARACNe",
#' group_name = "cell_type",
#' group_exclude = c("NK", "Monocyte"),
Expand All @@ -900,7 +904,7 @@ getActivity_individual <- function(input_eset,
#' do.z_normalization = TRUE)
#'
#' ## 5. when calculate the activities from the gene expression values scaled by other methods (e.g. ScaleData() from Seurat package)
#' activity.eset <- getActivity_inBatch(input_eset = normalized.eset,
#' activity.eset <- getActivity_inBatch(input_eset = pbmc14k_expression.eset,
#' sjaracne_dir = "./SJARACNe",
#' group_name = "cell_type",
#' network_tag.tf = "bs_100",
Expand Down
60 changes: 37 additions & 23 deletions R/visualization.R
Original file line number Diff line number Diff line change
Expand Up @@ -149,24 +149,26 @@ feature_vlnplot <- function(input_eset,
#' @export
#'
#' @examples
#' data(pbmc14k_expression.eset)
#'
#' ## 1. violin plots grouped by clusters (say the column name is 'clusterID')
#' p_box <- feature_boxplot(input_eset = clustered.eset,
#' p_box <- feature_boxplot(input_eset = pbmc14k_expression.eset,
#' features = c("CD14", "CD19", "CD8A"),
#' group_by = "clusterID")
#'
#' ## 2. violin plots grouped by cell types (say the column name is 'cellType')
#' p_box <- feature_boxplot(input_eset = clustered.eset,
#' p_box <- feature_boxplot(input_eset = pbmc14k_expression.eset,
#' features = c("CD14", "CD19", "CD8A"),
#' group_by = "cellType")
#'
#' ## 3. customize the colors to fill the violin plots
#' p_box <- feature_boxplot(input_eset = clustered.eset,
#' p_box <- feature_boxplot(input_eset = pbmc14k_expression.eset,
#' features = c("CD14", "CD19", "CD8A"),
#' group_by = "clusterID",
#' colors = c("blue", "red", "green"))
#'
#' ## 4. add jittered points
#' p_box <- feature_boxplot(input_eset = clustered.eset,
#' p_box <- feature_boxplot(input_eset = pbmc14k_expression.eset,
#' features = c("CD14", "CD19", "CD8A"),
#' group_by = "clusterID",
#' add_jitter = TRUE,
Expand Down Expand Up @@ -260,18 +262,20 @@ feature_boxplot <- function(input_eset,
#' @export
#'
#' @examples
#' data(pbmc14k_expression.eset)
#'
#' ## 1. scatter plots with UMAP projections
#' feature_scatterplot(input_eset = clustered.eset,
#' feature_scatterplot(input_eset = pbmc14k_expression.eset,
#' features = c("CD14", "CD19", "CD8A"),
#' location_x = "UMAP_1", location_y = "UMAP_2")
#'
#' ## 2. scatter plots with t-SNE projections
#' feature_scatterplot(input_eset = clustered.eset,
#' feature_scatterplot(input_eset = pbmc14k_expression.eset,
#' features = c("CD14", "CD19", "CD8A"),
#' location_x = "tSNE_1", location_y = "tSNE_2")
#'
#' ## 3. change the point size and font size
#' feature_scatterplot(input_eset = clustered.eset,
#' feature_scatterplot(input_eset = pbmc14k_expression.eset,
#' features = c("CD14", "CD19", "CD8A"),
#' location_x = "UMAP_1", location_y = "UMAP_2",
#' point.size = 1,
Expand Down Expand Up @@ -356,14 +360,16 @@ feature_scatterplot <- function(input_eset,
#' @export
#'
#' @examples
#' features_of_interest <- c("CD3D","CD27","IL7R","SELL","CCR7","IL32","GZMA","GZMK","DUSP2","CD8A","GZMH","GZMB","CD79A","CD79B","CD86","CD14")
#' data(pbmc14k_expression.eset)
#' features_of_interest <- c("CD3D","CD27","IL7R","SELL","CCR7","IL32","GZMA","GZMK",
#' "DUSP2","CD8A","GZMH","GZMB","CD79A","CD79B","CD86","CD14")
#' ## 1. the most commonly used command
#' feature_bubbleplot(input_eset = clustered.eset,
#' feature_bubbleplot(input_eset = pbmc14k_expression.eset,
#' features = features_of_interest,
#' group_by = "clusterID")
#'
#' ## 2. customize the colors
#' feature_bubbleplot(input_eset = clustered.eset,
#' feature_bubbleplot(input_eset = pbmc14k_expression.eset,
#' features = features_of_interest,
#' group_by = "clusterID",
#' colors = c("lightgrey", "red"))
Expand Down Expand Up @@ -445,32 +451,34 @@ feature_bubbleplot <- function(input_eset,
#' @export
#'
#' @examples
#' features_of_interest <- c("CD3D","CD27","IL7R","SELL","CCR7","IL32","GZMA","GZMK","DUSP2","CD8A","GZMH","GZMB","CD79A","CD79B","CD86","CD14")
#' data(pbmc14k_expression.eset)
#' features_of_interest <- c("CD3D","CD27","IL7R","SELL","CCR7","IL32","GZMA","GZMK",
#' "DUSP2","CD8A","GZMH","GZMB","CD79A","CD79B","CD86","CD14")
#' ## 1. the most commonly used command
#' feature_heatmap(input_eset = clustered.eset,
#' feature_heatmap(input_eset = pbmc14k_expression.eset,
#' features = features_of_interest,
#' group_by = "clusterID")
#'
#' ## 2. add one more column ('true_label') for cell annotation
#' feature_heatmap(input_eset = clustered.eset,
#' feature_heatmap(input_eset = pbmc14k_expression.eset,
#' features = features_of_interest,
#' group_by = "clusterID",
#' annotation_columns = c("true_label"))
#'
#' ## 3. scale the data by row
#' feature_heatmap(input_eset = clustered.eset,
#' feature_heatmap(input_eset = pbmc14k_expression.eset,
#' features = features_of_interest,
#' group_by = "clusterID",
#' scale_method = "row")
#'
#' ## 4. cluster the rows
#' feature_heatmap(input_eset = clustered.eset,
#' feature_heatmap(input_eset = pbmc14k_expression.eset,
#' features = features_of_interest,
#' group_by = "clusterID",
#' cluster_rows = TRUE)
#'
#' ## 5. add gaps
#' feature_heatmap(input_eset = clustered.eset,
#' feature_heatmap(input_eset = pbmc14k_expression.eset,
#' features = features_of_interest,
#' group_by = "clusterID",
#' use_gaps.column = TRUE,
Expand Down Expand Up @@ -554,13 +562,15 @@ feature_heatmap <- function(input_eset,
#' @export
#'
#' @examples
#' data(pbmc14k_expression.eset)
#'
#' ## 1. bar plot grouped by clusters ("clusterID") and colored by true labels ("true_label)
#' draw_barplot(input_eset = clustered.eset,
#' draw_barplot(input_eset = pbmc14k_expression.eset,
#' group_by = "clusterID",
#' color_by = "true_label")
#'
#' ## 2. customize the colors
#' draw_barplot(input_eset = clustered.eset,
#' draw_barplot(input_eset = pbmc14k_expression.eset,
#' group_by = "clusterID",
#' color_by = "true_label",
#' colors = c("green", "red", "blue", "grey", "orange", "purple", "yellow"))
Expand Down Expand Up @@ -618,16 +628,18 @@ draw_barplot <- function(input_eset,
#' @export
#'
#' @examples
#' marker_file <- system.file('PBMC14KDS_DemoDataSet/DATA/', 'Immune_signatures.xlsx', package = "scMINER")
#' data(pbmc14k_expression.eset)
#' marker_file <- system.file('extdata/demo_pbmc14k/PBMC14k_signatureTable.txt', package = "scMINER")
#' signature_table <- openxlsx::read.xlsx(marker_file)
#' head(signature_table)
#'
#' ## 1. the most commonly used command
#' draw_bubbleplot(input_eset = clustered.eset,
#' draw_bubbleplot(input_eset = pbmc14k_expression.eset,
#' signature_table = signature_table,
#' group_by = "clusterID")
#'
#' ## 2. customize the colors
#' draw_bubbleplot(input_eset = clustered.eset,
#' draw_bubbleplot(input_eset = pbmc14k_expression.eset,
#' signature_table = signature_table,
#' group_by = "clusterID",
#' colors = c("lightgrey", "red"))
Expand Down Expand Up @@ -730,8 +742,10 @@ draw_bubbleplot <- function(input_eset,
#' @export
#'
#' @examples
#' data(pbmc14k_expression.eset)
#'
#' ## 1. the most commonly used command
#' generatePortalInputs(input_expression.eset = expression_clustered.eset,
#' generatePortalInputs(input_expression.eset = pbmc14k_expression.eset,
#' group_by = "cellType",
#' input_activity.eset = activity_clustered.eset,
#' input_network.dir = "./SJARACNe",
Expand All @@ -748,7 +762,7 @@ draw_bubbleplot <- function(input_eset,
#' "./sjaracne/CD4Treg/TF/consensus_network_ncol_.txt",
#' "./sjaracne/B/SIG/consensus_network_ncol_.txt",
#' "./sjaracne/B/TF/consensus_network_ncol_.txt"))
#' generatePortalInputs(input_expression.eset = expression_clustered.eset,
#' generatePortalInputs(input_expression.eset = pbmc14k_expression.eset,
#' group_by = "cellType",
#' input_network.table = network.table,
#' output_dir = "./path-to-output_dir")
Expand Down
3 changes: 2 additions & 1 deletion man/compare2groups.Rd

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

6 changes: 4 additions & 2 deletions man/draw_barplot.Rd

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

8 changes: 5 additions & 3 deletions man/draw_bubbleplot.Rd

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

Loading

0 comments on commit 8e47308

Please sign in to comment.