I have a code where I generate random letter-sequences (randseq(20)) in DNA and output number of occurrences from a function. I want to group them so that all occurrences where the two first letters are equal is added together. I collect all outputs in a cell array:
5×2 cell array
C =
'GA' [ 0]
'AA' [ 0]
'CC' [ 2]
'CC' [ 2]
'AT' [42]
I want to group them such that all occurrences of e.g CC is in one group, in order to plot it in a bar chart.
Hope anyone can help me! Best regards

2 Kommentare

Jan
Jan am 2 Dez. 2017
What do you want to plot in the bar graph? What does "grouping" mean here exactly?
Andy
Andy am 2 Dez. 2017
I want to plot total number of (values)/occureences over each categorical letter-combination. So I want to have a cell array/table or something similar, and for the example given above, I would like:
C =
4 x 2 cell array
'GA' [ 0]
'AA' [ 0]
'CC' [ 4]
'AT' [42]
And then to be able to plot this in a bar graph, with the x-axis being the letter-combinations and the y-axis is the values(occurances).

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Star Strider
Star Strider am 2 Dez. 2017

0 Stimmen

If you put your data in a categorical array (see the documentation on Categorical Arrays (link)), you can use the countcats (link) function.

1 Kommentar

Andy
Andy am 2 Dez. 2017
Thank you for your help, but I could not make it work yet. I can make the character cells categorical, but then they loose their values in C(:,2)). These values are double-precision. Here is what I would like it to look like for the example given above:
C =
4 x 2 cell array
'GA' [ 0]
'AA' [ 0]
'CC' [ 4]
'AT' [42]

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Discrete Data Plots finden Sie in Hilfe-Center und File Exchange

Produkte

Gefragt:

am 2 Dez. 2017

Kommentiert:

am 2 Dez. 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by