Loading data and libraroes

library("dslabs")
library(tidyverse)
library(ggthemes)
library(ggrepel)
library(corrplot)
library(RColorBrewer)
data("brca")

Examining the data

##write_csv(brca, "brca.csv")
brca <- read_csv("brca.csv")
View(brca)
head(brca)
## # A tibble: 6 × 32
##    ...1 x.radi…¹ x.tex…² x.per…³ x.are…⁴ x.smo…⁵ x.com…⁶ x.con…⁷ x.con…⁸ x.sym…⁹
##   <dbl>    <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>
## 1     1    13.5     14.4    87.5    566.  0.0978  0.0813  0.0666 0.0478    0.188
## 2     2    13.1     15.7    85.6    520   0.108   0.127   0.0457 0.0311    0.197
## 3     3     9.50    12.4    60.3    274.  0.102   0.0649  0.0296 0.0208    0.182
## 4     4    13.0     18.4    82.6    524.  0.0898  0.0377  0.0256 0.0292    0.147
## 5     5     8.20    16.8    51.7    202.  0.086   0.0594  0.0159 0.00592   0.177
## 6     6    12.0     14.6    78.0    449.  0.103   0.0909  0.0659 0.0275    0.168
## # … with 22 more variables: x.fractal_dim_mean <dbl>, x.radius_se <dbl>,
## #   x.texture_se <dbl>, x.perimeter_se <dbl>, x.area_se <dbl>,
## #   x.smoothness_se <dbl>, x.compactness_se <dbl>, x.concavity_se <dbl>,
## #   x.concave_pts_se <dbl>, x.symmetry_se <dbl>, x.fractal_dim_se <dbl>,
## #   x.radius_worst <dbl>, x.texture_worst <dbl>, x.perimeter_worst <dbl>,
## #   x.area_worst <dbl>, x.smoothness_worst <dbl>, x.compactness_worst <dbl>,
## #   x.concavity_worst <dbl>, x.concave_pts_worst <dbl>, …

Visualizing the correlation between variables

summary(brca)
##       ...1     x.radius_mean    x.texture_mean  x.perimeter_mean
##  Min.   :  1   Min.   : 6.981   Min.   : 9.71   Min.   : 43.79  
##  1st Qu.:143   1st Qu.:11.700   1st Qu.:16.17   1st Qu.: 75.17  
##  Median :285   Median :13.370   Median :18.84   Median : 86.24  
##  Mean   :285   Mean   :14.127   Mean   :19.29   Mean   : 91.97  
##  3rd Qu.:427   3rd Qu.:15.780   3rd Qu.:21.80   3rd Qu.:104.10  
##  Max.   :569   Max.   :28.110   Max.   :39.28   Max.   :188.50  
##   x.area_mean     x.smoothness_mean x.compactness_mean x.concavity_mean 
##  Min.   : 143.5   Min.   :0.05263   Min.   :0.01938    Min.   :0.00000  
##  1st Qu.: 420.3   1st Qu.:0.08637   1st Qu.:0.06492    1st Qu.:0.02956  
##  Median : 551.1   Median :0.09587   Median :0.09263    Median :0.06154  
##  Mean   : 654.9   Mean   :0.09636   Mean   :0.10434    Mean   :0.08880  
##  3rd Qu.: 782.7   3rd Qu.:0.10530   3rd Qu.:0.13040    3rd Qu.:0.13070  
##  Max.   :2501.0   Max.   :0.16340   Max.   :0.34540    Max.   :0.42680  
##  x.concave_pts_mean x.symmetry_mean  x.fractal_dim_mean  x.radius_se    
##  Min.   :0.00000    Min.   :0.1060   Min.   :0.04996    Min.   :0.1115  
##  1st Qu.:0.02031    1st Qu.:0.1619   1st Qu.:0.05770    1st Qu.:0.2324  
##  Median :0.03350    Median :0.1792   Median :0.06154    Median :0.3242  
##  Mean   :0.04892    Mean   :0.1812   Mean   :0.06280    Mean   :0.4052  
##  3rd Qu.:0.07400    3rd Qu.:0.1957   3rd Qu.:0.06612    3rd Qu.:0.4789  
##  Max.   :0.20120    Max.   :0.3040   Max.   :0.09744    Max.   :2.8730  
##   x.texture_se    x.perimeter_se     x.area_se       x.smoothness_se   
##  Min.   :0.3602   Min.   : 0.757   Min.   :  6.802   Min.   :0.001713  
##  1st Qu.:0.8339   1st Qu.: 1.606   1st Qu.: 17.850   1st Qu.:0.005169  
##  Median :1.1080   Median : 2.287   Median : 24.530   Median :0.006380  
##  Mean   :1.2169   Mean   : 2.866   Mean   : 40.337   Mean   :0.007041  
##  3rd Qu.:1.4740   3rd Qu.: 3.357   3rd Qu.: 45.190   3rd Qu.:0.008146  
##  Max.   :4.8850   Max.   :21.980   Max.   :542.200   Max.   :0.031130  
##  x.compactness_se   x.concavity_se    x.concave_pts_se   x.symmetry_se     
##  Min.   :0.002252   Min.   :0.00000   Min.   :0.000000   Min.   :0.007882  
##  1st Qu.:0.013080   1st Qu.:0.01509   1st Qu.:0.007638   1st Qu.:0.015160  
##  Median :0.020450   Median :0.02589   Median :0.010930   Median :0.018730  
##  Mean   :0.025478   Mean   :0.03189   Mean   :0.011796   Mean   :0.020542  
##  3rd Qu.:0.032450   3rd Qu.:0.04205   3rd Qu.:0.014710   3rd Qu.:0.023480  
##  Max.   :0.135400   Max.   :0.39600   Max.   :0.052790   Max.   :0.078950  
##  x.fractal_dim_se    x.radius_worst  x.texture_worst x.perimeter_worst
##  Min.   :0.0008948   Min.   : 7.93   Min.   :12.02   Min.   : 50.41   
##  1st Qu.:0.0022480   1st Qu.:13.01   1st Qu.:21.08   1st Qu.: 84.11   
##  Median :0.0031870   Median :14.97   Median :25.41   Median : 97.66   
##  Mean   :0.0037949   Mean   :16.27   Mean   :25.68   Mean   :107.26   
##  3rd Qu.:0.0045580   3rd Qu.:18.79   3rd Qu.:29.72   3rd Qu.:125.40   
##  Max.   :0.0298400   Max.   :36.04   Max.   :49.54   Max.   :251.20   
##   x.area_worst    x.smoothness_worst x.compactness_worst x.concavity_worst
##  Min.   : 185.2   Min.   :0.07117    Min.   :0.02729     Min.   :0.0000   
##  1st Qu.: 515.3   1st Qu.:0.11660    1st Qu.:0.14720     1st Qu.:0.1145   
##  Median : 686.5   Median :0.13130    Median :0.21190     Median :0.2267   
##  Mean   : 880.6   Mean   :0.13237    Mean   :0.25427     Mean   :0.2722   
##  3rd Qu.:1084.0   3rd Qu.:0.14600    3rd Qu.:0.33910     3rd Qu.:0.3829   
##  Max.   :4254.0   Max.   :0.22260    Max.   :1.05800     Max.   :1.2520   
##  x.concave_pts_worst x.symmetry_worst x.fractal_dim_worst      y            
##  Min.   :0.00000     Min.   :0.1565   Min.   :0.05504     Length:569        
##  1st Qu.:0.06493     1st Qu.:0.2504   1st Qu.:0.07146     Class :character  
##  Median :0.09993     Median :0.2822   Median :0.08004     Mode  :character  
##  Mean   :0.11461     Mean   :0.2901   Mean   :0.08395                       
##  3rd Qu.:0.16140     3rd Qu.:0.3179   3rd Qu.:0.09208                       
##  Max.   :0.29100     Max.   :0.6638   Max.   :0.20750
cormat <- cor(brca[,2:11])
round(cormat, 2)
##                    x.radius_mean x.texture_mean x.perimeter_mean x.area_mean
## x.radius_mean               1.00           0.32             1.00        0.99
## x.texture_mean              0.32           1.00             0.33        0.32
## x.perimeter_mean            1.00           0.33             1.00        0.99
## x.area_mean                 0.99           0.32             0.99        1.00
## x.smoothness_mean           0.17          -0.02             0.21        0.18
## x.compactness_mean          0.51           0.24             0.56        0.50
## x.concavity_mean            0.68           0.30             0.72        0.69
## x.concave_pts_mean          0.82           0.29             0.85        0.82
## x.symmetry_mean             0.15           0.07             0.18        0.15
## x.fractal_dim_mean         -0.31          -0.08            -0.26       -0.28
##                    x.smoothness_mean x.compactness_mean x.concavity_mean
## x.radius_mean                   0.17               0.51             0.68
## x.texture_mean                 -0.02               0.24             0.30
## x.perimeter_mean                0.21               0.56             0.72
## x.area_mean                     0.18               0.50             0.69
## x.smoothness_mean               1.00               0.66             0.52
## x.compactness_mean              0.66               1.00             0.88
## x.concavity_mean                0.52               0.88             1.00
## x.concave_pts_mean              0.55               0.83             0.92
## x.symmetry_mean                 0.56               0.60             0.50
## x.fractal_dim_mean              0.58               0.57             0.34
##                    x.concave_pts_mean x.symmetry_mean x.fractal_dim_mean
## x.radius_mean                    0.82            0.15              -0.31
## x.texture_mean                   0.29            0.07              -0.08
## x.perimeter_mean                 0.85            0.18              -0.26
## x.area_mean                      0.82            0.15              -0.28
## x.smoothness_mean                0.55            0.56               0.58
## x.compactness_mean               0.83            0.60               0.57
## x.concavity_mean                 0.92            0.50               0.34
## x.concave_pts_mean               1.00            0.46               0.17
## x.symmetry_mean                  0.46            1.00               0.48
## x.fractal_dim_mean               0.17            0.48               1.00
corrplot(cormat)

Visualizing the relationship between nucleeus area and the number of concave portions of the nucleus contour by outcomes

ggplot(brca, aes(x.area_mean,  x.concave_pts_mean, color = y)) +  
  geom_point(size=1)+
  theme_dark()+
  theme(legend.position = c(0.8, 0.2), text=element_text(size=10))+
  geom_smooth(method = "loess")+
  scale_color_manual(values=c("lightblue", "#ff96a7"), labels = c("Benign", "Malignant"))+
  labs(x = "Nucleus area", y = "Number of concave portions of the nucleus contour", 
       title = "Malignant tumors generally have a larger nucleus area and more concave portions",
       colour = "Outcome",
       caption = "Source: UCI Machine Learning Repository")

Essay

This visualization uses the Breast Cancer Wisconsin Diagnostic Dataset from UCI Machine Learning Repository. The dataset describes 30 characteristics of cell nuclei from 569 breast masses as well as the outcome of each biopsy. The scatter plot above shows the relationship between three variables: mean nucleus area, mean number of concave portions of the nucleus contour, and the outcome of the biopsy. The nucleus area and number of concave portions are presented on the x and y axes, respectively. The outcomes are visualized by color, with the light blue color representing the benign tumors and the pink color representing the malignant tumors. The loess curve shows the trends between the variables by outcome.