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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ Suggests:
testthat (>= 3.0.0)
biocViews: Software
Config/testthat/edition: 3
RoxygenNote: 7.3.2
RoxygenNote: 7.3.3
VignetteBuilder: knitr
38 changes: 38 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ export(average_samples)
export(bar_number)
export(colData)
export(consensus_clustering_analysis)
export(filter_by_condition)
export(get_cluster_heatmap)
export(get_density)
export(global_filter)
export(glycoPSM_barplot)
export(impute)
export(make_se_customized)
Expand Down Expand Up @@ -68,12 +70,22 @@ importFrom(SNFtool,spectralClustering)
importFrom(SNFtool,standardNormalization)
importFrom(SummarizedExperiment,"assay<-")
importFrom(SummarizedExperiment,"colData<-")
importFrom(SummarizedExperiment,"metadata<-")
importFrom(SummarizedExperiment,"rowData<-")
importFrom(SummarizedExperiment,SummarizedExperiment)
importFrom(SummarizedExperiment,assay)
importFrom(SummarizedExperiment,colData)
importFrom(SummarizedExperiment,metadata)
importFrom(SummarizedExperiment,rowData)
importFrom(assertthat,assert_that)
importFrom(circlize,colorRamp2)
importFrom(cluster,daisy)
importFrom(clusterProfiler,GSEA)
importFrom(clusterProfiler,bitr)
importFrom(clusterProfiler,gseGO)
importFrom(clusterProfiler,gseKEGG)
importFrom(clusterProfiler,read.gmt)
importFrom(clusterProfiler,setReadable)
importFrom(cmapR,GCT)
importFrom(cmapR,ids)
importFrom(cmapR,mat)
Expand All @@ -85,11 +97,14 @@ importFrom(data.table,melt.data.table)
importFrom(data.table,setDT)
importFrom(dplyr,all_of)
importFrom(dplyr,arrange)
importFrom(dplyr,ends_with)
importFrom(dplyr,filter)
importFrom(dplyr,group_by)
importFrom(dplyr,if_all)
importFrom(dplyr,left_join)
importFrom(dplyr,mutate)
importFrom(dplyr,n)
importFrom(dplyr,pull)
importFrom(dplyr,recode)
importFrom(dplyr,rename)
importFrom(dplyr,select)
Expand All @@ -100,6 +115,7 @@ importFrom(dplyr,summarize)
importFrom(fdrtool,fdrtool)
importFrom(ggplot2,aes)
importFrom(ggplot2,aes_string)
importFrom(ggplot2,annotate)
importFrom(ggplot2,coord_fixed)
importFrom(ggplot2,element_blank)
importFrom(ggplot2,element_line)
Expand All @@ -110,8 +126,11 @@ importFrom(ggplot2,geom_boxplot)
importFrom(ggplot2,geom_col)
importFrom(ggplot2,geom_histogram)
importFrom(ggplot2,geom_jitter)
importFrom(ggplot2,geom_line)
importFrom(ggplot2,geom_point)
importFrom(ggplot2,geom_text)
importFrom(ggplot2,geom_text_repel)
importFrom(ggplot2,geom_violin)
importFrom(ggplot2,geom_vline)
importFrom(ggplot2,ggplot)
importFrom(ggplot2,ggplot_build)
Expand All @@ -128,9 +147,18 @@ importFrom(ggplot2,scale_x_continuous)
importFrom(ggplot2,scale_y_continuous)
importFrom(ggplot2,theme)
importFrom(ggplot2,theme_bw)
importFrom(ggplot2,theme_classic)
importFrom(ggplot2,theme_void)
importFrom(ggplot2,xlab)
importFrom(ggplot2,ylab)
importFrom(ggplotify,as.ggplot)
importFrom(ggrepel,geom_text_repel)
importFrom(grDevices,colorRampPalette)
importFrom(grDevices,dev.off)
importFrom(grDevices,png)
importFrom(grid,gpar)
importFrom(grid,grid.rect)
importFrom(grid,grid.text)
importFrom(grid,unit)
importFrom(httr,GET)
importFrom(limma,contrasts.fit)
Expand All @@ -145,10 +173,20 @@ importFrom(plotly,layout)
importFrom(plotly,plot_ly)
importFrom(purrr,map_df)
importFrom(readr,parse_factor)
importFrom(scales,percent)
importFrom(stats,complete.cases)
importFrom(stats,cor)
importFrom(stats,kmeans)
importFrom(stats,lm)
importFrom(stats,mad)
importFrom(stats,median)
importFrom(stats,prcomp)
importFrom(stringr,str_count)
importFrom(tibble,column_to_rownames)
importFrom(tibble,is_tibble)
importFrom(tibble,rownames_to_column)
importFrom(tidyr,gather)
importFrom(tidyr,replace_na)
importFrom(tidyr,spread)
importFrom(tidyr,unite)
importFrom(vsn,predict)
Expand Down
48 changes: 48 additions & 0 deletions R/filter.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#' Filter proteins by missing values globally
#'
#' \code{global_filter} removes proteins that have missing values in more than
#' a given percentage of all samples.
#'
#' @param se SummarizedExperiment, proteomics data.
#' @param percentage Numeric, maximum percentage of missing values allowed
#' across all samples (0-100). Default is 50.
#' @return A filtered SummarizedExperiment object.
#' @examples
#' data("ccrcc", package = "FragPipeAnalystR")
#' filtered <- global_filter(ccrcc, percentage = 50)
#'
#' @export
global_filter <- function(se, percentage=50){
percentage <- percentage / 100
ridx <- rowSums(is.na(assay(se))) / ncol(assay(se)) <= percentage
se <- se[ridx,]
return(se)
}

#' Filter proteins by missing values per condition
#'
#' \code{filter_by_condition} retains proteins that are observed in at least
#' \code{min_percentage} of samples in at least one condition.
#'
#' @param se SummarizedExperiment, proteomics data. Must have a \code{condition}
#' column in \code{colData}.
#' @param min_percentage Numeric, minimum percentage of non-missing values
#' required within at least one condition (0-100). Default is 50.
#' @return A filtered SummarizedExperiment object.
#' @examples
#' data("ccrcc", package = "FragPipeAnalystR")
#' filtered <- filter_by_condition(ccrcc, min_percentage = 50)
#'
#' @export
filter_by_condition <- function(se, min_percentage=50) {
min_percentage <- min_percentage / 100
conditions <- unique(colData(se)$condition)
row_ids <- rep(0, nrow(assay(se)))
for (c in conditions){
se_c <- se[,colData(se)$condition == c]
ridx <- rowSums(!is.na(assay(se_c))) / ncol(assay(se_c)) >= min_percentage
row_ids <- row_ids + ridx
}
se <- se[row_ids > 0,]
return(se)
}
Loading