Heatmap: Creating Heatmaps in R: Visualizing Complex Data Patterns

1. Introduction to Heatmaps and Their Importance in Data Visualization

Heatmaps are a powerful tool in the realm of data visualization, offering a means to represent complex data sets in a clear and comprehensible manner. They employ color in a strategic way to communicate relationships between data values that would be much harder to understand in a non-visual format. The importance of heatmaps lies in their ability to highlight trends, variances, and patterns in data that might not be immediately apparent from raw data sets. For instance, in the field of biology, heatmaps are crucial for illustrating gene expression levels across different conditions or treatments. Similarly, in web analytics, they can show which parts of a webpage are most interacted with by users.

From the perspective of a data scientist, heatmaps are invaluable for exploratory data analysis. They allow for a quick assessment of correlations and can point out anomalies in large data sets. From a business analyst's viewpoint, heatmaps can distill complex customer data into actionable insights, revealing areas of opportunity and concern. Meanwhile, for the end-user or stakeholder, heatmaps provide an accessible way to digest the findings of complex analyses without needing to understand the underlying statistics.

Here's an in-depth look at the utility of heatmaps in data visualization:

1. Pattern Recognition: Heatmaps simplify the detection of consistent patterns across data. For example, a heatmap of sales data over time can reveal seasonal trends or the impact of marketing campaigns.

2. Correlation Analysis: By organizing data in a matrix format, heatmaps can help identify correlations between variables. A positive correlation might be represented by a warm color, while a negative correlation might be shown with a cool color.

3. Data Comparison: Heatmaps enable the comparison of different data sets side-by-side. This is particularly useful in genomics, where one might compare gene expression under different experimental conditions.

4. Anomaly Detection: Deviations from the norm stand out on a heatmap. In cybersecurity, for instance, a sudden change in color could indicate a potential security breach.

5. user Experience optimization: In website analytics, heatmaps can track where users click, how far they scroll, and what they ignore, providing insights into how to improve the user interface.

6. Resource Allocation: Heatmaps can guide decision-making about where to allocate resources. A heatmap of social media engagement might show which regions are most responsive to certain types of content.

To illustrate, consider a heatmap used in a retail context to analyze customer foot traffic. Different shades of color could indicate the frequency of visits to different sections of a store. This visual representation could help store managers understand which areas attract the most customers and at what times, leading to more informed decisions about product placement and staffing.

In summary, heatmaps serve as a bridge between raw data and actionable insights, making them an essential component of data visualization in various fields. Their ability to condense and clarify complex information makes them particularly useful in today's data-driven world.

Introduction to Heatmaps and Their Importance in Data Visualization - Heatmap: Creating Heatmaps in R: Visualizing Complex Data Patterns

Introduction to Heatmaps and Their Importance in Data Visualization - Heatmap: Creating Heatmaps in R: Visualizing Complex Data Patterns

2. Installing and Loading the Necessary R Packages

Embarking on the journey of creating heatmaps in R begins with the foundational step of installing and loading the necessary packages. This process is akin to gathering your tools before embarking on a scientific expedition; without the right tools, one cannot hope to visualize the complex data patterns that heatmaps can reveal. The R ecosystem offers a plethora of packages designed to simplify this task, each bringing its own strengths to the table. From the widely-used `ggplot2` for its versatile data visualization capabilities to the specialized `pheatmap` for producing polished heatmaps, and `RColorBrewer` for an extensive range of color palettes, the choices are abundant. The installation process is straightforward, typically involving a simple command such as `install.packages("package_name")`. However, the loading of these packages using `library(package_name)` is where the true magic begins, as it unlocks the functions and datasets contained within, ready for the user to wield in their data analysis arsenal.

Here's an in-depth look at the steps involved:

1. Install `ggplot2`: Begin by installing `ggplot2`, a package that provides a powerful framework for creating complex visualizations. It's a staple for any data visualization task in R.

```R

Install.packages("ggplot2")

Library(ggplot2)

```

2. Install `reshape2`: Heatmaps require data in a matrix format. The `reshape2` package is instrumental in transforming your data to fit this need.

```R

Install.packages("reshape2")

Library(reshape2)

```

3. Install `pheatmap`: For a more specialized heatmap creation, `pheatmap` offers additional functionality for clustering and improved aesthetics.

```R

Install.packages("pheatmap")

Library(pheatmap)

```

4. Install `RColorBrewer`: This package provides a selection of color palettes that can enhance the interpretability and visual appeal of your heatmaps.

```R

Install.packages("RColorBrewer")

Library(RColorBrewer)

```

5. Data Preparation: Before plotting, ensure your data is in the correct format. The `melt` function from `reshape2` can convert data frames to the required matrix format.

```R

Data_matrix <- melt(your_data_frame, id.vars = "ID_column")

```

6. Creating a Basic Heatmap: With `ggplot2`, you can create a basic heatmap using the `geom_tile()` function, which visualizes data in a matrix format.

```R

Ggplot(data_matrix, aes(x = Var1, y = Var2, fill = value)) +

Geom_tile()

```

7. Enhancing Your Heatmap: Utilize `pheatmap` for advanced features like clustering and annotation, which can provide deeper insights into your data.

```R

Pheatmap(data_matrix, cluster_rows = TRUE, cluster_cols = TRUE)

```

8. Customizing Colors: Apply color palettes from `RColorBrewer` to your heatmap for better visual differentiation of data points.

```R

Heatmap_colors <- brewer.pal(9, "Blues")

Pheatmap(data_matrix, color = heatmap_colors)

```

By following these steps, you can install and load the necessary R packages to start creating informative and visually appealing heatmaps. Each package plays a pivotal role in the process, from data manipulation to the final presentation of results. Remember, the beauty of R lies in its community-driven packages, each contributing to a comprehensive toolkit for data analysis and visualization. As you progress, you'll find that the synergy between these packages can unlock even more complex and insightful patterns within your data. Happy heatmapping!

Installing and Loading the Necessary R Packages - Heatmap: Creating Heatmaps in R: Visualizing Complex Data Patterns

Installing and Loading the Necessary R Packages - Heatmap: Creating Heatmaps in R: Visualizing Complex Data Patterns

3. Preparing Your Data for Heatmap Creation

When embarking on the journey of creating a heatmap in R, the preparation of your data is a pivotal step that cannot be overstated. This process involves a meticulous approach to ensure that the data not only accurately represents the underlying patterns you wish to visualize but also aligns with the technical requirements of R's heatmap functions. From the perspective of a data scientist, this means scrutinizing every variable and value, whereas a statistician might emphasize the importance of the distribution and range of the data. A graphic designer, on the other hand, would focus on how the data's organization will translate visually. Each viewpoint contributes to a comprehensive understanding of the task at hand.

Here's an in-depth look at the steps involved:

1. Data Cleaning: Begin by removing any irrelevant information or outliers that may skew the results. For example, if you're visualizing temperature data across different cities, ensure that all measurements are in the same unit.

2. Normalization: Standardize your data to bring everything to a common scale, especially if you're comparing variables that operate on different ranges. For instance, you might use the formula $$ z = \frac{(x - \mu)}{\sigma} $$ to normalize your data, where \( x \) is the original value, \( \mu \) is the mean, and \( \sigma \) is the standard deviation.

3. Data Transformation: Depending on your data's nature, you might need to transform it to better fit a heatmap's requirements. Logarithmic transformation is common when dealing with data that spans several orders of magnitude.

4. Missing Values: Decide how to handle missing data. Imputation methods can fill in gaps, or you might choose to leave them blank, which some heatmap functions can accommodate as 'NA' values.

5. Hierarchical Clustering: If you plan to use clustering in your heatmap, pre-calculate the dendrograms for rows and columns. This step is crucial for large datasets where on-the-fly computation can be computationally expensive.

6. color Scheme selection: choose a color palette that not only is aesthetically pleasing but also provides clear differentiation between data points. For example, a gradient from blue (low) to red (high) is a common choice for representing temperature data.

7. Annotation Preparation: If your heatmap will include annotations, prepare this metadata in advance. For instance, if you're annotating gene expression data, you might include gene names or functional classifications.

8. Matrix Format: Ensure your data is in a matrix format that R's heatmap function can interpret. This typically means rows represent one variable (like time points) and columns another (like temperature readings).

9. Test Runs: Perform test runs with a subset of your data to fine-tune the parameters of the heatmap function. This step can save time and resources before processing the entire dataset.

10. Documentation: Keep detailed notes on the steps you've taken to prepare your data. This documentation is invaluable for reproducibility and for troubleshooting any issues that arise.

By following these steps, you'll be well on your way to creating a meaningful and visually impactful heatmap in R. Remember, the quality of your heatmap is directly tied to the quality of your data preparation. Happy mapping!

Preparing Your Data for Heatmap Creation - Heatmap: Creating Heatmaps in R: Visualizing Complex Data Patterns

Preparing Your Data for Heatmap Creation - Heatmap: Creating Heatmaps in R: Visualizing Complex Data Patterns

4. Colors, Clusters, and Annotations

Customizing the appearance of heatmaps in R is an essential step to enhance the interpretability and aesthetic appeal of your data visualization. The ability to modify colors, clusters, and annotations allows you to tailor the heatmap to your specific dataset and the story you want to tell. Whether you're working with gene expression data, sales figures, or complex algorithms, the right customization can turn a simple heatmap into a rich, informative canvas. From choosing a color palette that represents the data distribution effectively to clustering similar data points for better pattern recognition, each aspect plays a pivotal role. Annotations add another layer of context, providing on-the-spot insights without cluttering the visual.

Here's an in-depth look at how you can customize your heatmap in R:

1. Color Palettes: The choice of color can significantly affect the readability of your heatmap. R offers various functions to set the color gradient, such as `heatmap()` and `heatmap.2()` from the `gplots` package. You can use pre-defined palettes like `rainbow`, `heat.colors`, or create your own using the `colorRampPalette()` function.

- Example: To create a blue to red gradient, you might use:

```R

My_palette <- colorRampPalette(c("blue", "white", "red"))(n = 299)

Heatmap(x, col = my_palette)

```

2. Data Clustering: Heatmaps often incorporate hierarchical clustering to group similar data points. This is controlled by the `hclust` function in R, which can be customized with different methods like "complete", "average", or "ward.D2".

- Example: For average linkage clustering:

```R

Hc <- hclust(dist(x), method = "average")

Heatmap(x, Rowv = as.dendrogram(hc), Colv = NA)

```

3. Annotations: Adding annotations can provide immediate insights. With the `ComplexHeatmap` package, you can use the `HeatmapAnnotation()` function to add row or column annotations, which can be text, colors, or even plots.

- Example: To add row annotations based on a factor variable:

```R

Ha <- HeatmapAnnotation(df = data.frame(Group = factor(rep(c("A", "B"), each = 50))),

Col = list(Group = c("A" = "green", "B" = "red")))

Heatmap(x, top_annotation = ha)

```

4. Adjusting Breaks: The `breaks` argument in heatmap functions allows you to define the points where the color changes, which can be crucial for highlighting specific ranges of values.

- Example: To set breaks for values between 0 and 1:

```R

Heatmap(x, breaks = seq(0, 1, length.out = 100), col = my_palette)

```

5. Interactive Heatmaps: For a more dynamic experience, you can create interactive heatmaps using packages like `shiny` and `plotly`. This allows users to hover over cells to get more information, zoom in/out, and even click to get detailed reports.

By carefully considering these elements, you can create a heatmap that not only conveys the complex patterns in your data but also tells a compelling story. Remember, the goal is to make the data as accessible and engaging as possible, and these customization options are your tools to achieve that.

Colors, Clusters, and Annotations - Heatmap: Creating Heatmaps in R: Visualizing Complex Data Patterns

Colors, Clusters, and Annotations - Heatmap: Creating Heatmaps in R: Visualizing Complex Data Patterns

5. Understanding the Story Behind the Data

Heatmaps are a powerful tool in data visualization, allowing us to see complex data patterns through color gradients. They are particularly useful when analyzing data that has multiple variables or when looking for patterns and correlations across a dataset. The beauty of a heatmap lies in its simplicity; it transforms numbers into a visual language that can be quickly understood. However, the true art of using heatmaps is in the interpretation – understanding the story that the data is telling us.

From a statistician's perspective, a heatmap is not just a table with colors; it's a narrative of distribution and density. Each color transition can signify a shift in the data, pointing to outliers, clusters, or trends that warrant further investigation. For a business analyst, a heatmap can highlight areas of opportunity or risk, showing where customer engagement is highest or where a process is bottlenecking.

Here are some in-depth insights into interpreting heatmaps:

1. Color Significance: The choice of color scale is crucial. Typically, warm colors (reds, oranges) indicate higher values and cool colors (blues, greens) lower values. It's important to ensure that the color gradient is intuitive and accessible to all viewers, including those with color vision deficiencies.

2. Clustering: Heatmaps often reveal clusters, which are groups of similar data points. Identifying these can lead to insights about the underlying structure of the data. For example, in a heatmap showing website traffic, clusters may indicate common user behavior patterns.

3. Outliers: Just as important as the clusters are the outliers – data points that stand out because they're not like the others. These can be critical in fields like quality control or fraud detection, where an outlier might indicate a defect or an anomaly.

4. Scale and Normalization: The scale of the data can greatly affect the interpretation of a heatmap. Sometimes, normalizing the data (so that values fall between 0 and 1, for instance) can make patterns more apparent.

5. Annotations: Adding annotations to a heatmap can provide context that the colors alone cannot convey. This might include labeling significant clusters or outliers, or adding a side chart to explain the color scale.

6. Interactivity: In digital formats, heatmaps can be made interactive, allowing users to hover over or click on sections to get more information. This can greatly enhance the interpretability of the heatmap.

7. Comparative Analysis: Using heatmaps to compare different datasets side-by-side can reveal similarities and differences that might not be apparent when looking at the data separately.

To illustrate, let's consider a heatmap that shows the performance of various sales teams across different regions. The warmest colors might highlight regions where sales are booming, immediately drawing the eye. Cooler colors might indicate regions where sales are lower, prompting questions about why these differences exist. Are there external factors at play, or does it come down to the strategies employed by the teams?

Interpreting heatmaps is about much more than just recognizing the presence of colors. It's about understanding what those colors represent, the context in which they exist, and the stories they tell about the data. By considering these various aspects, one can extract meaningful insights and make informed decisions based on complex data patterns.

Understanding the Story Behind the Data - Heatmap: Creating Heatmaps in R: Visualizing Complex Data Patterns

Understanding the Story Behind the Data - Heatmap: Creating Heatmaps in R: Visualizing Complex Data Patterns

6. Creating Interactive Heatmaps with Shiny

Interactive heatmaps are a powerful tool for visualizing complex data patterns, and Shiny, an R package, provides a dynamic platform to create these visualizations. By leveraging Shiny's reactive programming model, you can build heatmaps that respond to user input, allowing for a more engaging and insightful exploration of datasets. This capability is particularly useful in fields such as bioinformatics, finance, and social sciences, where understanding the nuances within large datasets is crucial.

From a developer's perspective, creating an interactive heatmap in Shiny involves several advanced techniques:

1. Data Preparation: Before you can visualize data, it must be cleaned and structured appropriately. This often involves transforming the data into a matrix format, with rows and columns corresponding to the variables of interest.

2. UI Design: The user interface (UI) is where users interact with your heatmap. In Shiny, you can design a UI with sliders, dropdowns, and other input controls to manipulate the heatmap dynamically.

3. Server Logic: The server side of a Shiny app contains the instructions for building the heatmap based on user input. This is where you define the reactive elements that update the visualization.

4. Heatmap Rendering: Using packages like `ggplot2` or `plotly`, you can render the heatmap within the Shiny app. These packages offer functions to adjust the color scale, clustering, and other heatmap parameters.

5. Reactivity: To make the heatmap interactive, you use Shiny's reactive expressions, which automatically update the output when the user changes an input.

6. Performance Optimization: For large datasets, performance can be an issue. Techniques like pre-processing data, using efficient algorithms, and minimizing reactive events can help improve the responsiveness of your app.

7. Deployment: Once your app is ready, you can deploy it to a server or a Shiny hosting platform, making it accessible to users worldwide.

For example, imagine a heatmap that displays gene expression levels across different conditions. A researcher could use sliders to adjust the range of expression levels they're interested in, and the heatmap would immediately update to reflect this, highlighting genes that meet the criteria in a different color.

By integrating these advanced techniques, you can create a Shiny app that not only presents data but also invites users to interact with it, leading to a deeper understanding of the underlying patterns and insights. Interactive heatmaps are not just static representations; they become exploratory tools that can adapt to the user's needs and questions.

Creating Interactive Heatmaps with Shiny - Heatmap: Creating Heatmaps in R: Visualizing Complex Data Patterns

Creating Interactive Heatmaps with Shiny - Heatmap: Creating Heatmaps in R: Visualizing Complex Data Patterns

7. Analyzing Gene Expression Data with Heatmaps

Heatmaps are a powerful visualization tool in the field of bioinformatics, particularly when it comes to the analysis of gene expression data. They provide a color-coded representation of the data, making it easier to identify patterns and correlations that might not be immediately apparent from raw numerical data. In the context of gene expression, heatmaps can be used to display the level of expression of thousands of genes across different conditions or time points, offering insights into the biological processes at play.

From the perspective of a biologist, heatmaps are invaluable for hypothesis generation. For instance, genes that show similar patterns of expression are often functionally related or co-regulated. This can lead to the discovery of new gene networks or pathways involved in a particular disease or physiological process. From a computational biologist's point of view, heatmaps are a way to reduce dimensionality, summarizing complex data in a form that is amenable to pattern recognition and clustering algorithms.

Here are some in-depth points about analyzing gene expression data with heatmaps:

1. Data Normalization: Before creating a heatmap, it's crucial to normalize the gene expression data to account for variability between samples. Techniques such as z-score normalization or log transformation are commonly used.

2. Clustering: Heatmaps often incorporate clustering algorithms, like hierarchical clustering, to group genes with similar expression patterns. This can reveal functional groups or regulatory mechanisms.

3. Color Scheme: The choice of color gradient is important for interpretability. Typically, red indicates high expression, blue low expression, and yellow intermediate levels. The color intensity should accurately reflect the magnitude of expression changes.

4. Annotations: Adding annotations to heatmaps can greatly enhance their informational value. For example, annotating rows (genes) with gene function or pathways can provide immediate biological context.

5. Interactivity: Modern bioinformatics tools allow for the creation of interactive heatmaps where users can zoom in on areas of interest, click on genes to get more information, or reorganize the data based on different parameters.

6. Reproducibility: Ensuring that the code and methods used to generate heatmaps are well-documented is essential for reproducibility and further analysis by peers.

To illustrate these points, let's consider an example where a researcher is studying the response of cancer cells to a new drug. They perform RNA sequencing at multiple time points post-treatment and generate a heatmap of gene expression. The heatmap reveals a cluster of genes that are upregulated in response to the drug, which upon further investigation, are found to be related to the cell's stress response. This insight could lead to a better understanding of the drug's mechanism of action and potentially inform the development of combination therapies.

In summary, heatmaps are a synthesis of art and science, transforming complex gene expression data into a format that is both informative and aesthetically pleasing. They bridge the gap between raw data and actionable biological insights, making them an indispensable tool in the modern biologist's arsenal.

Analyzing Gene Expression Data with Heatmaps - Heatmap: Creating Heatmaps in R: Visualizing Complex Data Patterns

Analyzing Gene Expression Data with Heatmaps - Heatmap: Creating Heatmaps in R: Visualizing Complex Data Patterns

8. Troubleshooting Common Issues in Heatmap Generation

Heatmaps are a powerful tool for visualizing complex data patterns, especially in the realm of bioinformatics and data science. They allow researchers and analysts to see trends and anomalies, presenting a comprehensive overview of the information at hand. However, generating heatmaps can sometimes be fraught with challenges that can skew the results or render the visualization unreadable. From data preprocessing to the final display, each step in the heatmap generation process has its potential pitfalls. Understanding these common issues is crucial for anyone looking to leverage the full power of heatmaps in R.

1. Inadequate Data Preprocessing: Before even beginning to generate a heatmap, it's essential to ensure that the data is properly preprocessed. This includes normalizing or standardizing the data to make sure that the scale of the values does not distort the heatmap. For example, if one column of data ranges from 0 to 1 and another from 0 to 100, without normalization, the heatmap will be dominated by the larger range.

2. Choosing the Wrong Clustering Method: Heatmaps often use clustering to group similar data points together. The choice of clustering algorithm can greatly affect the outcome. Hierarchical clustering is a common choice, but it may not always be the best option, especially for large datasets where k-means or DBSCAN might be more appropriate.

3. Misinterpreting the Color Scale: The color scale in a heatmap is its most critical feature. It's important to choose a color palette that provides good contrast and is interpretable by the intended audience. For instance, using a red-green color scale might not be suitable for color-blind individuals, and using too many colors can make the heatmap confusing.

4. Overplotting: When dealing with large datasets, overplotting can occur, where too many data points overlap and make the heatmap unreadable. One way to address this is by using data aggregation or binning techniques to reduce the granularity of the data.

5. Ignoring the Aspect Ratio: The aspect ratio of a heatmap can significantly affect its readability. If the cells are too elongated or too squished, it can be difficult to discern patterns. Adjusting the aspect ratio to ensure that cells are as square as possible can help alleviate this issue.

6. Not Annotating the Heatmap: Annotations can add valuable context to a heatmap, such as labeling clusters or highlighting significant data points. For example, adding text labels to indicate groups of genes in a genomic heatmap can provide insights that would otherwise be missed.

7. Poor Documentation of the Process: Finally, it's essential to document the entire process of heatmap generation, including the R code used, the data preprocessing steps, and the rationale behind the choices made. This ensures that the heatmap is reproducible and that others can understand and trust the results.

Generating heatmaps in R is a nuanced process that requires careful consideration at each step. By being aware of common issues and how to troubleshoot them, one can create clear, informative, and impactful visualizations that accurately reflect the underlying data. Remember, the goal is not just to create a visually appealing heatmap, but one that conveys the right information in the most effective way possible.

9. Integrating Heatmaps into Larger Data Analysis Workflows

Heatmaps are a powerful visualization tool that can reveal complex data patterns through color gradients. They are particularly useful in bioinformatics for gene expression data, in finance for correlation matrices, and in web analytics for user behavior tracking. However, the true potential of heatmaps is unlocked when they are integrated into larger data analysis workflows. This integration allows for a more comprehensive understanding of the data, as heatmaps can be used to highlight trends, pinpoint outliers, and direct further analysis.

From a data scientist's perspective, integrating heatmaps into larger workflows involves several steps:

1. Data Preparation: Before creating a heatmap, the data must be cleaned and normalized. This ensures that the heatmap accurately reflects the underlying patterns.

2. Selection of Variables: Deciding which variables to include in the heatmap is crucial. Too many variables can make the heatmap cluttered and difficult to interpret.

3. choosing the Right Color scheme: The color scheme must be chosen carefully to ensure that it is accessible to all viewers, including those with color vision deficiencies.

4. Clustering: Implementing clustering algorithms can help group similar data points together, making patterns more apparent.

5. Annotation: Adding annotations to the heatmap can provide context and make it easier to understand the significance of certain data points.

For example, in a genomic study, researchers might use a heatmap to display gene expression levels across different conditions. They could then use clustering to group genes with similar expression patterns, which might indicate shared regulatory mechanisms.

From a business analyst's perspective, heatmaps can be integrated into dashboards to monitor KPIs and other metrics. This can be done by:

1. real-time data Integration: Connecting the heatmap to live data sources can help businesses respond quickly to changes.

2. Interactivity: Adding interactive elements, such as the ability to zoom or filter the heatmap, can help users explore the data in more depth.

3. Comparative Analysis: Using heatmaps to compare different time periods or segments can highlight changes and trends.

For instance, a heatmap could be used to track website user engagement over time, with different colors indicating levels of activity. By comparing heatmaps from different weeks, a business can identify when and where user engagement peaks.

In education, heatmaps can be used to analyze student performance and engagement. Educators might:

1. Track Progress: Use heatmaps to visualize student progress over time, identifying areas where students are excelling or struggling.

2. Customize Learning: Adjust teaching strategies based on the heatmap analysis to better cater to individual student needs.

3. Engage Students: Incorporate heatmaps in classroom activities to teach students about data visualization and interpretation.

An example here could be a heatmap showing the results of a class test, with colors representing different score ranges. This can quickly show which topics the class as a whole found challenging.

Integrating heatmaps into larger data analysis workflows is a multifaceted process that requires careful consideration of the data, the audience, and the objectives of the analysis. By doing so, heatmaps become not just a standalone visualization, but a gateway to deeper insights and more informed decision-making.

Integrating Heatmaps into Larger Data Analysis Workflows - Heatmap: Creating Heatmaps in R: Visualizing Complex Data Patterns

Integrating Heatmaps into Larger Data Analysis Workflows - Heatmap: Creating Heatmaps in R: Visualizing Complex Data Patterns