Skip to content

Commit

Permalink
Merge pull request #326 from mixOmicsTeam/issue-307
Browse files Browse the repository at this point in the history
PR addressing Issue #307
  • Loading branch information
evaham1 authored Oct 22, 2024
2 parents e4c8d56 + 718ceb2 commit 1b9f04a
Show file tree
Hide file tree
Showing 4 changed files with 758 additions and 49 deletions.
35 changes: 18 additions & 17 deletions R/internal_graphicModule.R
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ internal_graphicModule <-
group.pch = "different"
}

df$pch.levels = factor(as.character(df$pch.levels)) #forced to be character,
# removed code to force as.character below because pch.levels should never be reordered, always the same (1, 2, 3, 4..) and they should always match the order of df$group levels
df$pch.levels = factor(as.numeric(df$pch.levels))
#df$pch.levels = factor(as.character(df$pch.levels)) #forced to be character,
# so that the order of the levels is the same all the time
# (1, 10, 11, 12, 2, 3...), instead of changing between ggplot2 and
# the rest
Expand Down Expand Up @@ -218,25 +220,22 @@ internal_graphicModule <-


#-- Modify scale colour - Change X/Ylabel - split plots into Blocks
p = p + scale_color_manual(values = unique(col.per.group)[match(
levels(factor(as.character(df$group))), levels(df$group))],
name = legend.title)
## order of 'col.per.group' will correspond to order of levels in 'df$group'
p = p + scale_color_manual(values = col.per.group, name = legend.title)


if(group.pch == "same")
{
p = p + scale_shape_manual(values = values.pch[match(
levels(factor(as.character(df$pch.levels))),levels(df$pch.levels))],
p = p + scale_shape_manual(values = values.pch,
name = legend.title, labels = levels(factor(df$group)),
guide = "none")
#match(..) reorder the values as the values of pch.levels,
#if there's more than 10 levels, R/ggplot orders characters
#different than values 1, 10, 11, 2, 3, etc
} else {
# if pch different factor, then second legend
p = p + scale_shape_manual(values = values.pch[match(
levels(factor(as.character(df$pch.levels))),levels(df$pch.levels))],
name = legend.title.pch, labels = levels(df$pch.levels))
p = p + scale_shape_manual(values = values.pch,
name = legend.title.pch, labels = values.pch)
}

p = p + #labs(list(title = title, x = X.label, y = Y.label)) +
Expand Down Expand Up @@ -294,12 +293,13 @@ internal_graphicModule <-
if (display.names | any(class.object%in%object.mint) ) {
group.shape <- 19
} else {
group.shape <- unique(df$pch.legend)
# keep order of pch.levels the same
group.shape <- as.numeric(levels(df$pch.levels))

if (length(group.shape) > 1)
{
names(group.shape) <- unique(df$group)
group.shape <- group.shape[sort(names(group.shape))]
# keep order of df$group levels the same
names(group.shape) <- levels(df$pch.legend)
}
}

Expand Down Expand Up @@ -398,8 +398,7 @@ internal_graphicModule <-
}

#-- Modify scale colour - Change X/Ylabel - split plots into Blocks
p = p + scale_colour_manual(values = unique(col.per.group)[match(
levels(factor(as.character(df$group))), levels(df$group))],
p = p + scale_colour_manual(values = unique(col.per.group),
name = legend.title) +
labs(shape = "Study")#levels(object$study)[study.ind])

Expand Down Expand Up @@ -812,9 +811,11 @@ internal_graphicModule <-
lwd=point.lwd)#,...)
} else {
points(x = df[df$col == i & other, "x"],
y = df[df$col == i & other, "y"],
col = df[df$col == i, ]$col, cex = df[df$col == i, ]$cex,
pch = df[df$col == i, ]$pch,lwd=point.lwd)#,...)
y = df[df$col == i & other, "y"],
col = df[df$col == i, ]$col,
cex = df[df$col == i, ]$cex,
pch = as.numeric(df[df$col == i, ]$pch.levels),
lwd=point.lwd)#,...)
}
}

Expand Down
3 changes: 2 additions & 1 deletion R/plotIndiv.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
#' @param group factor indicating the group membership for each sample, useful
#' for ellipse plots. Coded as default for the supervised methods \code{PLS-DA,
#' SPLS-DA,sGCCDA}, but needs to be input for the unsupervised methods
#' \code{PCA, sPCA, IPCA, sIPCA, PLS, sPLS, rCC, rGCCA, sGCCA}
#' \code{PCA, sPCA, IPCA, sIPCA, PLS, sPLS, rCC, rGCCA, sGCCA}. Order of levels will reflect
#' order in legends and correspond to any set colours.
#' @template arg/col.per.group
#' @param style argument to be set to either \code{'graphics'},
#' \code{'lattice'}, \code{'ggplot2'} or \code{'3d'} for a style of plotting.
Expand Down
3 changes: 2 additions & 1 deletion man/plotIndiv.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1b9f04a

Please sign in to comment.