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

Add heatmap caption and alt text #161

Closed
wants to merge 3 commits into from
Closed
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
16 changes: 10 additions & 6 deletions _episodes_rmd/03-regression-regularisation.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ when we have more features than observations.
> `methylation` dataset (we selected 500 features only as it can be hard to
> visualise patterns when there are too many features!).
>
> ```{r corr-mat-meth, fig.cap="Cap", fig.alt="Alt"}
library("ComplexHeatmap")
> ```{r corr-mat-meth, fig.cap="Heatmap of pairwise feature-feature correlations between CpG sites in DNA methylation data", fig.alt="A symmetrical heatmap where rows and columns are features in a DNA methylation dataset. Colour corresponds to correlation, with red being large positive correlations and blue being large negative correlations. There are large blocks of deep red and blue throughout the plot."}
> library("ComplexHeatmap")
> small <- methyl_mat[, 1:500]
> cor_mat <- cor(small)
> Heatmap(cor_mat,
Expand Down Expand Up @@ -295,7 +295,11 @@ avoid estimating very large effect sizes.
> > "ordinary least squares". The "ordinary" really means "original" here,
> > to distinguish between this method, which dates back to ~1800, and some
> > more "recent" (think 1940s...) methods.
> > 2. Least squares assumes that, when we account for the change in the mean of
> > 2. Squared error is useful because it ignores the *sign* of the residuals
> > (whether they are positive or negative).
> > It also penalises large errors much more than small errors.
> > On top of all this, it also makes the solution very easy to compute mathematically.
> > Least squares assumes that, when we account for the change in the mean of
> > the outcome based on changes in the income, the data are normally
> > distributed. That is, the *residuals* of the model, or the error
> > left over after we account for any linear relationships in the data,
Expand Down Expand Up @@ -381,9 +385,9 @@ Now let's fit a linear model to our training data and calculate the training err
fit_horvath <- lm(train_age ~ ., data = as.data.frame(train_mat))

## Function to calculate the (mean squared) error
mse <- function(true, prediction) {
mean((true - prediction)^2)
}
mse <- function(true, prediction) {
mean((true - prediction)^2)
}

## Calculate the training error
err_lm_train <- mse(train_age, fitted(fit_horvath))
Expand Down