TramineR proportion per cluster - r

I am new to TramineR and using seqdplot() command I created a plot to visualize cluster patterns. Is there a way to plot the proportions of each cluster (as seen on the plot below)?

To display the proportion, you can use the group.p function of TraMineRextras. The function adds the proportion to each group label.
Here is the example given in the help page:
library('TraMineRextras')
data(actcal)
actcal <- actcal[1:100,]
actcal.seq <- seqdef(actcal[,13:24])
seqdplot(actcal.seq, group=group.p(actcal$sex))

Related

How to add analysis of variance to a Bioconductor plot that combines jitter and boxplots?

I made a plot that shows median expression of some markers across different cell populations.
I made it using a Bioconductor package that is based on ggplot and the final result is a ggplot object. Here is the plot
and I want to be able to show an analysis of variance between the conditions (so between "Ref" and "BCRXL") for every antigen within every cell type. I was thinking I could use ggpubr since my plot is ggplot based, but I'm having difficulty.
p <- plotMedExprs(sce, k = "merging1",
facet_by = "cluster_id", shape_by = "patient_id")
p$facet$params$ncol <- 2
p
I know this is a complex plot, but any help would be appreciated! :)

Complexheatmap zoom annotation : Cluster wise boxplot

I want show cluster wise boxplot distribution from complexheatmap. I was able to do row-wise distribution but how do I implement the cluster-wise distribution attached as example.
In the dummy example it creates a subgroup which it shows in the distribution. Similar manner I have already in my datafile made cluster which is represented in the first column.
How do I implement this in my dataframe using this example code
I'm not sure how do I make subgroup in case of my dataframe.
Any suggestion or help would be really appreciated.
This is the output i would like to see:
This is the output I have:
The dataset is this one: small_data
And my code:
df <- read.csv("small_data.txt",header = TRUE)
heat <- t(scale(t(df[,3:ncol(df)])))
myBreaks <- seq(-1.5, 1.5, length.out=100)
hmap <- Heatmap(heat)
hmap
How do i implement the cluster specific distribution ? as it is shown in the first pic. The second figure is what I'm getting now

How to structure data for R?

So... newbie R user here. I have some observations that I'd like to record using R and be able to add to later.
The items are sorted by weights, and the number at each weight recorded. So far what I have looks like this:
weights <- c(rep(171.5, times=1), rep(171.6, times=2), rep(171.7, times=4), rep(171.8, times=18), rep(171.9, times=39), rep(172.0, times=36), rep(172.1, times=34), rep(172.2, times=25))
There will be a total of 500 items being observed.
I'm going to be taking additional observations over time to (hopefully) see how the distribution of weights changes with use/wear. I'd like to be able plots showing either stacked histograms or boxplots.
What would be the best way to format / store this data to facilitate this kind of use case? A matrix, dataframe, something else?
As other comments have suggest, the most versatile (and perhaps useful) container (structure) for your data would be a data frame - for use with the library(ggplot2) for your future plotting and graphing needs(such as BoxPlot with ggplot and various histograms
Toy example
All the code below does is use your weights vector above, to create a data frame with some dummy IDs and plot a box and whisker plot, and results in the below plot.
library(ggplot2)
IDs<-sample(LETTERS[1:5],length(weights),TRUE) #dummy ID values
df<-data.frame(ID=IDs,Weights=weights) #make data frame with your
#original `weights` vector
ggplot(data=df,aes(factor(ID),Weights))+geom_boxplot() #box-plot

How to deal with all data as non-outliers for boxplot in R?

I am new to R project and have to use boxplot function to plot the data.
When I use it, boxplot automatically deals with some points as outliers.
But for my case, every points are not outliers. I just wanted to show min/max, 25/75 percentile and median. So I've searched for boxplot function and haven't found an option that deals every points as non-outliers.
Is there any way to do what I want?
You should try using range=0. For example:
x <- rlnorm(1000)
boxplot(x, range = 0)

PCA biplot one variables shown R

I ran a pca on a set of 45000 genes on 5 different samples, and when I perform a biplot, all I see is a mass of text (responding to the observation names), and cannot see the location of my samples. Is there a way to plot the location of the samples only, and not the observation, in a biplot?
Using built in data from R
usa <- USArrests
pca1 <- prcomp(usa)
biplot(pca1)
This generates a biplot where all the states (observation names) overlap the variables (my different samples) rape, etc. Is it possible to plot only the variables (samples), and not the states (observation names)?
biplot.default uses text to write the categorical variable name of the observation. As it doesn't use points you need to modify the source if you only want the points (and not the labels) to be plotted.
However, you could "hack" it by doing something like:
biplot(pca1, xlabs = rep(".", nrow(usa)))
I hope this is what you're looking for!
Edit If this is not satisfactory, you can modify the source given when running stats:::biplot.default to use points.

Resources