Box plot and genetic data
2
0
Entering edit mode
3.5 years ago
L_LANKA • 0

Hi! I have a question about box plot and data. I made the correlation analysis Spearman. I see a positive connection between gene and phenotypic expression. For example, I have gene AAAA where 1 and 3 - homozygous and 2- heterozygote. I have information about temperature and I make graduation this information from 1 to 8 (1- 36.0-36.5; 2- 36.6 - 37.0 etc). Can I see how genotype correlation with phenotype in box plot graphic? (For example, if a patient has genotype 2 (C\T) so he\she can has temperature from 4 to 6). enter image description here

R gene • 1.5k views
ADD COMMENT
0
Entering edit mode

Can you edit your post and include some example data? It's difficult to help without more specific information.

ADD REPLY
0
Entering edit mode

Ok, no problem! :) I made a table and a temperature encryption key.

ADD REPLY
1
Entering edit mode
3.5 years ago

Some example data.

df <- data.frame(
  patient=sprintf("C%s", seq_len(10)),
  genotype=sample(seq_len(3), 10, replace=TRUE),
  temperature=sample(seq_len(7), 10, replace=TRUE)
)

> head(df, 5)
  patient genotype temperature
1      C1        1           4
2      C2        3           1
3      C3        1           3
4      C4        2           2
5      C5        1           6

A boxplot using ggplot2.

library("tidyverse")

df %>%
  mutate(genotype=as_factor(genotype)) %>%
  ggplot(aes(x=genotype, y=temperature)) +
    geom_boxplot()

enter image description here

Or a stacked barplot as Hamid Ghaedi correctly pointed out.

df %>%
  mutate(across(!patient, as_factor)) %>%
  ggplot(aes(x=genotype, fill=temperature)) +
    geom_bar(position="fill") +
    scale_fill_viridis_d()

enter image description here

ADD COMMENT
1
Entering edit mode
3.5 years ago

Important notice: Box-plot is usually use to show how a quantitative variable is distributed. Especially it does a great job when diffrneces in variance is significant between the groups and you expect to have some outliers ( Like gene expression data). Since you have discretized the tempreature data, using a box-plot for visualization does not make sense anymore, however, you can plot your original tempreature data as box-plot.

Now you have frequency data of tempreature per genotype, you can viusalize the data using a barplot (or prefreably stacked barplot).

ADD COMMENT

Login before adding your answer.

Traffic: 2725 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6