Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix additional URLs and a typo #253

Merged
merged 1 commit into from
Jan 19, 2024
Merged
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
17 changes: 4 additions & 13 deletions episodes/06-data-visualization.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,12 @@ library(readr)
library(dplyr)
```



As we can see from above output **`ggplot2`** has been already loaded along with other packages as part of the **`tidyverse`** framework.

## Loading the dataset

```{r load-the-dataset, echo=TRUE, eval=TRUE}
variants = read_csv("https://raw.githubusercontent.com/naupaka/vcfr-for-data-carpentry-draft/main/output/combined_tidy_vcf.csv")
variants <- read.csv("https://raw.githubusercontent.com/datacarpentry/genomics-r-intro/main/episodes/data/combined_tidy_vcf.csv")
```

Explore the *structure* (types of columns and number of rows) of the dataset using [dplyr](https://dplyr.tidyverse.org/index.html)'s [`glimpse()`](https://dplyr.tidyverse.org/reference/glimpse.html) (for more info, see the [Data Wrangling and Analyses with Tidyverse](https://datacarpentry.org/genomics-r-intro/05-dplyr/) episode)
Expand All @@ -95,13 +93,6 @@ Alternatively, we can display the first a few rows (vertically) of the table usi
head(variants)
```

```{r, echo=FALSE, eval=TRUE, purl=FALSE}
## silently read in CSV file from FigShare

# variants <- read.csv("https://ndownloader.figshare.com/files/14632895")
# variants = read.csv("https://raw.githubusercontent.com/naupaka/vcfr-for-data-carpentry-draft/main/output/combined_tidy_vcf.csv")
```

**`ggplot2`** functions like data in the **long** format, i.e., a column for every dimension (variable), and a row for every observation. Well-structured data will save you time when making figures with **`ggplot2`**

**`ggplot2`** graphics are built step-by-step by adding new elements. Adding layers in this fashion allows for extensive flexibility and customization of plots, and more equally important the readability of the code.
Expand Down Expand Up @@ -147,7 +138,7 @@ coverage_plot <- ggplot(data = variants, aes(x = POS, y = DP))

# Draw the plot
coverage_plot +
geom_point()
geom_point()
```

**Notes**
Expand Down Expand Up @@ -179,7 +170,7 @@ Then, we start modifying this plot to extract more information from it. For inst

```{r adding-transparency, purl=FALSE}
ggplot(data = variants, aes(x = POS, y = DP)) +
geom_point(alpha = 0.5)
geom_point(alpha = 0.5)
```

We can also add colors for all the points:
Expand Down Expand Up @@ -426,7 +417,7 @@ for inspiration. Here are some ideas:
:::::::::::::::::::::::::::::::::::::::: keypoints

- ggplot2 is a powerful tool for high-quality plots
- ggplot2 provides a flexiable and readable grammar to build plots
- ggplot2 provides a flexible and readable grammar to build plots

::::::::::::::::::::::::::::::::::::::::::::::::::

Expand Down