Principal Component Analysis (PCA) is a dimensionality reduction method that transforms data from a high-dimensional space into a low-dimensional space while retaining the original data's essential properties. This function calculates PCA using the classical prcomp function and visualizes the results.
A SummarizedExperiment object constructed by
as_summarized_experiment
and processed by data_process
.
(NOTE: A SummarizedExperiment object generated by deSp_twoGroup
,
deChar_twoGroup
, deSp_multiGroup
, or
deChar_multiGroup
is also allowed.)
Logical. If scaling=TRUE, each block is
standardized to zero means and unit variances. Default is TRUE
.
Logical. If centering=TRUE, the variables should be
shifted to be zero centered. Alternately, a vector of length equal the
number of columns of x can be supplied. The value is passed to scale. Default is TRUE
.
Character. The method to be used for clustering. Allowed method
include "kmeans", "kmedoids", "hclustering", "dbscan", "group_info". Default is "kmeans"
.
Numeric. A positive integer specifying the number of clusters.
The number must be between 1 and 10. Default is 2
.
Character. The metric to be used for calculating
dissimilarities between observations when choosing "kmedoids"
as clustering method.
Must be one of "euclidean" and "manhattan". If "kmedoids" is not selected as
the clustering method, set the value to NULL.
Character. The distance measure to be used when choosing "hclustering"
as clustering method. Allow method include "pearson", "kendall", "spearman",
"euclidean", "manhattan", "maximum", "canberra", "binary", and "minkowski".
If "hclustering" is not selected as the clustering method, set the value to NULL.
Character. The agglomeration method to be used when choosing
"hclustering"
as clustering method. This should be (an unambiguous abbreviation of)
one of "ward.D", "ward.D2", "single", "complete", "average" (=UPGMA),
"mcquitty" (= WPGMA), "median" (= WPGMC), or "centroid" (= UPGMC).
If "hclustering" is not selected as the clustering method, set the value to NULL.
Numeric. The size of the epsilon neighborhood when choosing "dbscan"
as clustering method.
If "dbscan" is not selected as the clustering method, set the value to NULL.
Numeric. The number of minimum points in the eps region (for core points)
when choosing "dbscan"
as clustering method.
If "dbscan" is not selected as the clustering method, set the value to NULL.
Numeric. The dimension(s) of interest.
Numeric. The number of top elements to be shown.
Return a list with 2 tables, 4 interactive plots, and 4 static plots.
pca_rotated_data: a data frame of PCA rotated data
table_pca_contribution: a data frame, PCA contribution table
interactive_pca & static_pca: PCA plot
interactive_screePlot & static_screePlot: Scree plot of top n principle components
interactive_feature_contribution & static_feature_contribution: plot, the contribution of top N features of the user-defined principal components.
interactive_variablePlot & static_variablePlot: correlation circle plot(factor map) of PCA variables.
data("profiling_data")
processed_se <- data_process(profiling_data, exclude_missing=TRUE, exclude_missing_pct=70,
replace_na_method='min', replace_na_method_ref=0.5, normalization='Percentage')
result_pca <- dr_pca(processed_se, scaling=TRUE, centering=TRUE,
clustering='kmeans', cluster_num=2, kmedoids_metric=NULL, distfun=NULL,
hclustfun=NULL, eps=NULL, minPts=NULL, feature_contrib_pc=c(1,2), plot_topN=10)
#> Warning: The following aesthetics were dropped during statistical transformation:
#> x_plotlyDomain, y_plotlyDomain
#> ℹ This can happen when ggplot fails to infer the correct grouping structure in
#> the data.
#> ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
#> variable into a factor?
#> Warning: `gather_()` was deprecated in tidyr 1.2.0.
#> ℹ Please use `gather()` instead.
#> ℹ The deprecated feature was likely used in the plotly package.
#> Please report the issue at <https://github.com/ropensci/plotly/issues>.
#> Warning: 'bar' objects don't have these attributes: 'mode'
#> Valid attributes include:
#> 'type', 'visible', 'showlegend', 'legendgroup', 'opacity', 'name', 'uid', 'ids', 'customdata', 'meta', 'selectedpoints', 'hoverinfo', 'hoverlabel', 'stream', 'transforms', 'uirevision', 'x', 'x0', 'dx', 'y', 'y0', 'dy', 'xperiod', 'yperiod', 'xperiod0', 'yperiod0', 'xperiodalignment', 'yperiodalignment', 'text', 'texttemplate', 'hovertext', 'hovertemplate', 'textposition', 'insidetextanchor', 'textangle', 'textfont', 'insidetextfont', 'outsidetextfont', 'constraintext', 'cliponaxis', 'orientation', 'base', 'offset', 'width', 'marker', 'offsetgroup', 'alignmentgroup', 'selected', 'unselected', 'r', 't', '_deprecated', 'error_x', 'error_y', 'xcalendar', 'ycalendar', 'xaxis', 'yaxis', 'idssrc', 'customdatasrc', 'metasrc', 'hoverinfosrc', 'xsrc', 'ysrc', 'textsrc', 'texttemplatesrc', 'hovertextsrc', 'hovertemplatesrc', 'textpositionsrc', 'basesrc', 'offsetsrc', 'widthsrc', 'rsrc', 'tsrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule', '_bbox'
#> Warning: geom_GeomTextRepel() has yet to be implemented in plotly.
#> If you'd like to see this geom implemented,
#> Please open an issue with your example code at
#> https://github.com/ropensci/plotly/issues