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)