Machine Learning Cheatsheet

February 3, 2021 · View on GitHub

The tables below consist of valuable functions or commands that will help you through this module.

Each table represents a different library/tool and its corresponding commands.

Please note that these tables are not intended to tell you all the information you need to know about each command.

The hyperlinks found in each piece of code will take you to the documentation for further information on the usage of each command.



AnnotationDbi

Read the AnnotationDbi package vignette here.

Library/PackagePiece of CodeWhat it's calledWhat it does
AnnotationDbikeytypes()KeytypesReturns a character vector of column names/keytypes (e.g., type of gene identifiers) available in an AnnotationDbi package.
AnnotationDbimapIDs()Mapped IDsExtracts the mapped ids for a set of keys (e.g., gene identifiers) of a specific keytype

Base R

Read the Base R package documentation here.

Library/PackagePiece of CodeWhat it's calledWhat it does
Base Rround()RoundRounds the values in the object provided in the first argument to the number of decimal places specified in the second argument
Base Ridentical()IdenticalChecks if two objects are exactly equal
Base Rprcomp()Principal Components AnalysisExecutes a principal components analysis on specified matrix or data frame
Base RrowSums()Row SumsReturns the sums of the rows in a numeric array, matrix, or data.frame
Base RrowMeans()Row MeansReturns the means of the rows in a numeric array, matrix, or data.frame
Base Rquantile()Sample QuantilesReturns the sample quantiles for a given numeric vector of data and numeric vector of probabilities
Base Rcor()CorrelationComputes correlation between columns using a specified correlation method, and returns a correlation matrix
Base Ras.dist()Distance matrix computationReturns a special object of class dist, a distance matrix used by the hclust() function
Base Rhclust()Hierarchical ClusteringPerforms hierarchical clustering analysis on a set of dissimilarities and methods
Base Rtable()Create TableCreates a contingency table of counts for each combination of factor levels
Base Rduplicated()DuplicatedReturns a logical vector, where TRUE represents elements of the object that are duplicates
Base Rany()AnyChecks to see if at least one of the elements are TRUE when given a logical vector
Base Rcbind()Column bindCombines vectors, matrices, or data.frames by columns
Base Rpairwise.wilcox.test()Pairwise Wilcoxon Rank Sum TestsCalculates the pairwise comparisons between group levels

PLIER

Read the PLIER package documentation here.
A PLIER package vignette can be found here and can also serve as documentation for the commands in the table below.

Library/PackagePiece of CodeWhat it's calledWhat it does
PLIERcombinePaths()Combine PathwaysCombines the pathway data obtained from PLIER and returns the result as a matrix
PLIERcommonRows()Common RowsDetermines the rows (genes) that are common to the specified data matrices and returns them as a character vector
PLIERrowNorm()Row NormalizeNormalizes each row (gene) by z-scoring the expression values
PLIERnum.pc()Number of Principal ComponentsReturns the number of significant principal components
PLIERPLIER()Main PLIER FunctionMain function of the Pathway-Level Information ExtractoR.
PLIERplotU()Plot U MatrixPlots the U matrix obtained from the PLIER function results, allowing insight into the pathways or cell types captured by the latent variables

ComplexHeatmap

Read the ComplexHeatmap package documentation here.

Library/PackagePiece of CodeWhat it's calledWhat it does
ComplexHeatmapHeatmap()Complex HeatmapConstructs a heatmap whose graphics and features can be defined
ComplexHeatmapHeatmapAnnotation()Heatmap Annotation ConstructorCreates an annotation object to be used in conjunction with a Heatmap


ggplot2

Read the ggplot2 package documentation here.
A vignette on the usage of the ggplot2 package can be found here.

Library/PackagePiece of CodeWhat it's calledWhat it does
ggplot2geom_jitter()Jittered PointsAdds a small amount of random variation at each point’s location on a plot
ggplot2labs()LabelsSets the axis, legend, and plot labels if specified
ggplot2theme()ThemeSets the specified non-data elements of a plot (i.e. plot title, legend spacing, text size, etc.)


tidyr

Read the tidyr package documentation here.
A vignette on the usage of the tidyr package can be found here.

Library/PackagePiece of CodeWhat it's calledWhat it does
tidyrseparate()SeparateSeparates a character column into multiple columns with a given regular expression or numeric locations
tidyrpivot_longer()Pivot LongerPivots data in a data.frame from wide to long format

Other packages and functions

Documentation for each of these packages can be accessed by clicking the package name in the table below.

Library/PackagePiece of CodeWhat it's calledWhat it does
data.tablefread()F readReads in data faster than base R
purrrdiscard()DiscardDiscards the given elements
dplyrpull()PullPulls a single variable out of a given table of data
matrixStatsrowSds()Row Standard DeviationsReturns the standard deviation estimates for each row in a matrix
matrixStatsrowVars()Row VariancesReturns the variance estimates for each row in a matrix
umapumap()Uniform Manifold Approximation and Projection (UMAP)Computes a manifold approximation and projection on a given matrix or data.frame
ConsensusClusterPlusConsensusClusterPlus()Consensus ClusteringFinds the consensus across multiple runs of the clustering algorithm
plotlyplot_ly()Plotly VisualizationInitiates a plotly visualization with given R objects
ggsignifgeom_signif()Create Significance LayerAdds significance information to the plot. It can be used to run statistical tests and display the significance information from those tests. We use it differently, in a way that gives us more control, in the notebook.