Nothing
#' @title quickTCPred
#' @description Creates a regression plot over the time course, which compares
#' data and a simulation which was predicted using the data. Data is based
#' on the model formula used in the multiReg function and linearRegr function.
#' R.squared and p value are also calculated and pasted into the plot.
#' @param model Linear model which was generated by the linearRegr function.
#' @param reg_df Matrix/assay which which was generated by the multiReg function.
#' Should be in the MAE used during the multiReg function.
#' @return A linear regression plot with data and a simulation.
#' @export
#' @usage quickTCPred(model, reg_df)
#' @importFrom ggplot2 geom_point
#' @importFrom stats predict
#' @examples
#' library(org.Mm.eg.db)
#'
#' miR <- mm_miR[1:100,]
#'
#' mRNA <- mm_mRNA[1:200,]
#'
#' MAE <- startObject(miR = miR, mRNA = mRNA)
#'
#' MAE <- getIdsMir(MAE, assay(MAE, 1), orgDB = org.Mm.eg.db, 'mmu')
#'
#' MAE <- getIdsMrna(MAE, assay(MAE, 2), "useast", 'mmusculus')
#'
#' MAE <- diffExpressRes(MAE, df = assay(MAE, 1), dataType = 'Log2FC',
#' genes_ID = assay(MAE, 3),
#' idColumn = 'GENENAME',
#' name = "miRNA_log2fc")
#'
#' MAE <- diffExpressRes(MAE, df = assay(MAE, 2), dataType = 'Log2FC',
#' genes_ID = assay(MAE, 7),
#' idColumn = 'GENENAME',
#' name = "mRNA_log2fc")
#'
#' Filt_df <- data.frame(row.names = c("mmu-miR-145a-3p:Adamts15",
#' "mmu-miR-146a-5p:Acy1"),
#' corr = c(-0.9191653, 0.7826041),
#' miR = c("mmu-miR-145a-3p", "mmu-miR-146a-5p"),
#' mRNA = c("Adamts15", "Acy1"),
#' miR_Entrez = c(387163, NA),
#' mRNA_Entrez = c(235130, 109652),
#' TargetScan = c(1, 0),
#' miRDB = c(0, 0),
#' Predicted_Interactions = c(1, 0),
#' miRTarBase = c(0, 1),
#' Pred_Fun = c(1, 1))
#'
#' MAE <- matrixFilter(MAE, miningMatrix = Filt_df, negativeOnly = FALSE,
#' threshold = 1, predictedOnly = FALSE)
#'
#' MAE <- multiReg(MAE = MAE, gene_interest = "Adamts15",
#' mRNAreg =TRUE, filt_df=MAE[[11]], miRNA_exp=MAE[[9]],
#' mRNA_exp=MAE[[10]])
#'
#' model1 <- linearRegr(mreg = MAE[[12]], colselect =2, colpair =3)
#'
#' summary(model1$regression)
#'
#' quickTCPred(model = model1, reg_df = MAE[[12]])
quickTCPred <- function(model, reg_df){
if (missing(model)) stop('model is missing. Add linear regression model generated by the linearRegr function.')
if (missing(reg_df)) stop('reg_df is missing. Add matrix/assay generated by the multiReg function.')
Time <- Values <- Simulation <- NULL
S <- summary(model$regression)
Rs <- round(S$r.squared, digits = 2)
Pval <- round(getP(model$regression), digits = 2)
Gene <- colnames(reg_df)[2]
Prediction <- predict(model$regression)
X <- cbind(Data = reg_df[,c(2)], Prediction)
rownames(X) <- as.integer(gsub(rownames(X), pattern = "[^0-9.-]",
replacement = ""))
X <- as.data.frame(X)
Melted <- melt(as.matrix(X), varnames = c("Time", "Simulation"))
names(Melted)[[3]] <- "Values"
ggplot(Melted, aes(x = Time, y = Values, group = Simulation,
color = Simulation)) +
geom_point(data = ~ subset(., Simulation == paste("Data")), size =5) +
geom_line(data = ~ subset(., Simulation == paste("Prediction")),
size =2, linetype = "dashed") +
scale_colour_manual(values=c("Red", "Blue"))+
theme_classic()+
labs(title= paste0(Gene,":Interactions Time Series Regression"),
x="Time",
y="Expression",
subtitle=paste0("R.sqrd = ", Rs, " |", " Pval = ", Pval))+
theme(plot.title=element_text(size=20, face="bold",hjust = 0.5),
axis.text.x=element_text(size=20),
axis.text.y=element_text(size=20),
axis.title.x=element_text(size=20),
axis.title.y=element_text(size=20),
legend.text=element_text(size=15))+
theme(plot.subtitle=element_text(size=20, hjust=1.2,
face="italic", color="black"))
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.