Skip to content

Commit

Permalink
update slides and links
Browse files Browse the repository at this point in the history
  • Loading branch information
caalo committed Nov 13, 2024
1 parent dc0c3b8 commit 809de85
Show file tree
Hide file tree
Showing 78 changed files with 6,316 additions and 22 deletions.
4 changes: 2 additions & 2 deletions 05-data-visualization.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Categorical (between 1 categorical and 1 continuous variable)

- Violin plots

[![Image source: Seaborn\'s overview of plotting functions](https://seaborn.pydata.org/_images/function_overview_8_0.png)](https://seaborn.pydata.org/tutorial/function_overview.html)
[![Image source: Seaborn's overview of plotting functions](https://seaborn.pydata.org/_images/function_overview_8_0.png)](https://seaborn.pydata.org/tutorial/function_overview.html)

Why do we focus on these common plots? Our eyes are better at distinguishing certain visual features more than others. All of these plots are focused on their position to depict data, which gives us the most effective visual scale.

Expand Down Expand Up @@ -182,4 +182,4 @@ plot = sns.displot(data=metadata, x="Age", hue="Sex", multiple="dodge", palette=

## Exercises

Exercise for week 5 can be found [here](https://colab.research.google.com/drive/1kT3zzq2rrhL1vHl01IdW5L1V7v0iK0wY?usp=sharing).
Exercise for week 5 can be found [here](https://colab.research.google.com/drive/17iwr8NwLLrmzRj4a6zRZucETXpPkmDNR?usp=sharing).
Binary file added images/student_stickers.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions slides/community2.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
title: "Python Community Session 1"
format:
revealjs:
smaller: true
scrollable: true
echo: true
output-location: fragment
---

## How to find new functions and methods

Suppose you want to learn more about Pandas Dataframes:

[Newcomer tutorials](https://pandas.pydata.org/docs/user_guide/10min.html)

[User guides](https://pandas.pydata.org/docs/user_guide/index.html)

[Package documentation page](https://pandas.pydata.org/docs/index.html)

- How to install the module?

- How to load in the module? What are some module functions?

- What kind of Objects are available for use?

## What kind of Objects are available for use?

- How to construct or load an Object?

- *What does it contain?*

- **Value** that holds the essential data for the object.

- **Attributes** that hold subset of the data or additional data for the object.

- *What can it do?*

- Functions called **Methods** specific to the data type and automatically takes the object as input.
Binary file added slides/images/student_stickers.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 22 additions & 20 deletions slides/lesson5_slides.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Once you load in the Dataframe, `my_df` is a Dataframe Object.

. . .

Ex. When we make a plot from `displot`, we get a FacetGrid object.
When we make a plot from `displot`, it returns a FacetGrid object.

## [What's your favorite plot??](https://docs.google.com/document/d/1-v4pYC7jh7EYHq7MtRLd0rfhurojGrskWy7Oy_GQfZY/edit?usp=sharing)

Expand All @@ -114,7 +114,7 @@ Ex. When we make a plot from `displot`, we get a FacetGrid object.

More to come!

## Why we like these common plots
## Why we like these plots

![](https://www.oreilly.com/api/v2/epubs/9781466508910/files/image/fig5-1.png)

Expand All @@ -134,31 +134,31 @@ Adjust the binwidth:
plot = sns.displot(data=metadata, x="Age", binwidth = 10)
```

## Distributions
## Conditional Distributions

What is the distribution of age when compared with sex? Age for Female, Age for Male, and Age for Unknown:
What is the distribution of age conditional on sex? Age for Female, Age for Male, and Age for Unknown:

```{python}
plot = sns.displot(data=metadata, x="Age", hue="Sex", binwidth=10)
```

## Distributions
## Conditional Distributions

We add a new option that we want to separate each bar category via `multiple="dodge"` input argument:

```{python}
plot = sns.displot(data=metadata, x="Age", hue="Sex", multiple="dodge", binwidth=10)
```

## Distributions
## Conditional Distributions

Or, separate the conditions via a subplot:

```{python}
plot = sns.displot(data=metadata, x="Age", col="Sex", binwidth=10)
```

You can find a lot more details about distributions and histograms in [the Seaborn tutorial](https://seaborn.pydata.org/tutorial/distributions.html).
More info [here](https://seaborn.pydata.org/tutorial/distributions.html).

## Relational

Expand All @@ -168,15 +168,7 @@ Specify the input argument `data` as our dataframe, and the input arguments `x`
plot = sns.relplot(data=expression, x="KRAS_Exp", y="EGFR_Exp")
```

## Relational

You can change the plot style via the `kind` argument to "line", but the visual interpretation changes.

```{python}
plot = sns.relplot(data=expression, x="KRAS_Exp", y="EGFR_Exp", kind="line")
```

## Relational
## Condition on Relational

To conditional on other variables, plotting features are used to distinguish conditional variable values:

Expand All @@ -194,22 +186,24 @@ Let's merge `expression` and `metadata` together, so that we can examine KRAS an
expression_metadata = expression.merge(metadata)
```

## Relational
## Condition on Relational

Examine KRAS and EGFR relationships conditional on primary vs. metastatic cancer status:

```{python}
plot = sns.relplot(data=expression_metadata, x="KRAS_Exp", y="EGFR_Exp", hue="PrimaryOrMetastasis")
```

## Relational
## Condition on Relational

More conditioning:

```{python}
plot = sns.relplot(data=expression_metadata, x="KRAS_Exp", y="EGFR_Exp", hue="PrimaryOrMetastasis", col="AgeCategory")
```

More on relational plots [here](https://seaborn.pydata.org/tutorial/relational.html).

## Categorical

Between one categorical and one continuous variable:
Expand All @@ -228,19 +222,22 @@ You can add additional conditional variables via the input arguments:

- `col`

## Categorical
## Condtion on Categorical

```{python}
plot = sns.catplot(data=expression_metadata, x="PrimaryOrMetastasis", y="EGFR_Exp", hue="AgeCategory")
```

More on categorical plots [here](https://seaborn.pydata.org/tutorial/categorical.html).

## "Kind" of plots

![Image source: Seaborn’s overview of plotting functions](https://seaborn.pydata.org/_images/function_overview_8_0.png)

For example, `sns.catplot(data=expression_metadata, x="PrimaryOrMetastasis", y="EGFR_Exp", hue="AgeCategory", kind="box")`

Try it out!
[Try it out, share with what you tried](https://docs.google.com/document/d/1-v4pYC7jh7EYHq7MtRLd0rfhurojGrskWy7Oy_GQfZY/edit?usp=sharing)


## Basic plot customization: color

Expand All @@ -255,6 +252,11 @@ plot = sns.displot(data=metadata, x="Age", hue="Sex", multiple="dodge", palette=

## [Cheatsheet, updated with Modules](https://docs.google.com/document/d/1si-4suESej1Vjopkv5KiI-hGylXk11osmO3oEfpYOuc/edit?usp=sharing)


## What to do next week?

<https://docs.google.com/document/d/17FsFWDOEuqTcHoWe-wl2Bz-xlsK0vGzqeiNBxMDkwXI/edit?usp=sharing>

## How was class for you today?

<https://forms.gle/8EGdEqcsp82GP82U9>
Loading

0 comments on commit 809de85

Please sign in to comment.