<p>I'm comparing gene expression among 2 different datasets (<em>in vivo</em> and <em>in vitro</em>) I have made a heatmap showing the correlation for each and then plotted the data frame to create a scatterplot. Now I want to just pull out KP4 from each data set and do the same scatterplot but then pull put genes that aren't on the linear line. How do I do that?</p>
<pre><code>###how to compare expression across both datasets??
# Plot the correlation heatmap of intersect genes between two datasets
dat_human.df_num &lt;- apply(dat_human.df,2,as.numeric)
rownames(dat_human.df_num) &lt;- rownames(dat_human.df)
colnames(dat_human.df_num) &lt;- c(&quot;KP4_invitro&quot;, &quot;L3.3_invitro&quot;, &quot;T3M4_invitro&quot;)
colnames(countmatrix_clean_cl) &lt;- c(&quot;KP4_invivo&quot;, &quot;T3M4_invivo&quot;, &quot;L3.3_invivo&quot;)
intersect.genes &lt;- intersect(rownames(countmatrix_clean_cl), rownames(dat_human.df_num))
length(intersect.genes) # 18786
#test &lt;- data.frame(cbind(countmatrix_clean_cl[intersect.genes,], dat_human.df_num[intersect.genes,]))
combined_data &lt;- data.frame(cbind(countmatrix_clean_cl[intersect.genes,], dat_human.df_num[intersect.genes,]))
head(combined_data)

melted_corr_mat &lt;- melt(cor(combined_data))
head(melted_corr_mat)

ggplot(data=melted_corr_mat, aes(x=Var1, y=Var2, fill=value)) + 
  geom_tile(color=&quot;white&quot;) + 
  scale_fill_gradient2(low=&quot;blue&quot;, high=&quot;red&quot;, mid=&quot;white&quot;, midpoint = mean(melted_corr_mat$value), space=&quot;Lab&quot;) + 
  geom_text(aes(Var2, Var1, label = round(value, digits=2)),
            color = &quot;black&quot;, size = 4) + 
  theme_minimal() + 
  labs(x=&quot;&quot;,y=&quot;&quot;) + 
  theme(axis.text.x=element_text(angle=45, vjust=1, hjust=1)) + 
  coord_fixed()
</code></pre>
<pre><code>### scatterplot for each cell line in each condition (in-vivo vs. in-vitro)
head(combined_data)
         KP4_invivo T3M4_invivo L3.3_invivo KP4_invitro L3.3_invitro T3M4_invitro
TSPAN6       24.084      12.762      24.877      31.043       69.536       30.780
TNMD          0.000       0.000       0.000       0.000        0.000        0.000
DPM1         56.015     100.402      60.142     101.408      149.830      214.116
SCYL3         3.470       5.474       8.940       6.889        9.599       10.494
C1orf112      7.910      15.051      12.932      19.363       28.695       38.230
FGR           0.042       0.776       0.128       0.010        0.392        0.361

plot(combined_data)
</code></pre>
<p><a href="https://i.sstatic.net/0pqIP.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/0pqIP.png" alt="in-vivo vs. in-vitro" /></a></p>

CC BY-SA 4.0
2022-03-29T13:09:44.847Z
I'm not sure how to perform differential expression on bulk?
mmpp
<r><rna-seq><ggplot2>
Pulling out genes in a scatterplot
# Pulling out genes in a scatterplot

(Asked by: username_0 on 2022-03-29)

I'm comparing gene expression among 2 different datasets (in vivo and in vitro) I have made a heatmap showing the correlation for each and then plotted the data frame to create a scatterplot. Now I want to just pull out KP4 from each data set and do the same scatterplot but then pull put genes that aren't on the linear line. How do I do that?
###how to compare expression across both datasets??
# Plot the correlation heatmap of intersect genes between two datasets
dat_human.df_num <- apply(dat_human.df,2,as.numeric)
rownames(dat_human.df_num) <- rownames(dat_human.df)
colnames(dat_human.df_num) <- c("KP4_invitro", "L3.3_invitro", "T3M4_invitro")
colnames(countmatrix_clean_cl) <- c("KP4_invivo", "T3M4_invivo", "L3.3_invivo")
intersect.genes <- intersect(rownames(countmatrix_clean_cl), rownames(dat_human.df_num))
length(intersect.genes) # 18786
#test <- data.frame(cbind(countmatrix_clean_cl[intersect.genes,], dat_human.df_num[intersect.genes,]))
combined_data <- data.frame(cbind(countmatrix_clean_cl[intersect.genes,], dat_human.df_num[intersect.genes,]))
head(combined_data)

melted_corr_mat <- melt(cor(combined_data))
head(melted_corr_mat)

ggplot(data=melted_corr_mat, aes(x=Var1, y=Var2, fill=value)) + 
  geom_tile(color="white") + 
  scale_fill_gradient2(low="blue", high="red", mid="white", midpoint = mean(melted_corr_mat$value), space="Lab") + 
  geom_text(aes(Var2, Var1, label = round(value, digits=2)),
            color = "black", size = 4) + 
  theme_minimal() + 
  labs(x="",y="") + 
  theme(axis.text.x=element_text(angle=45, vjust=1, hjust=1)) + 
  coord_fixed()

### scatterplot for each cell line in each condition (in-vivo vs. in-vitro)
head(combined_data)
         KP4_invivo T3M4_invivo L3.3_invivo KP4_invitro L3.3_invitro T3M4_invitro
TSPAN6       24.084      12.762      24.877      31.043       69.536       30.780
TNMD          0.000       0.000       0.000       0.000        0.000        0.000
DPM1         56.015     100.402      60.142     101.408      149.830      214.116
SCYL3         3.470       5.474       8.940       6.889        9.599       10.494
C1orf112      7.910      15.051      12.932      19.363       28.695       38.230
FGR           0.042       0.776       0.128       0.010        0.392        0.361

plot(combined_data)

**Tags:** r, rna-seq, ggplot2
> **Comments:**
> **username_0**: I'm not sure how to perform differential expression on bulk?  

---

## 0 answers

