pca with more than one grouping variable

4 ビュー (過去 30 日間)
Kim Arnold
Kim Arnold 2021 年 12 月 14 日
コメント済み: Jeff Miller 2021 年 12 月 16 日
I want to do a pca plot of 20 samples I measured. For this I used gscatter. However, I want
1) to color my samples with 7 colors for the different type of organisms i measured and in addition
2) I want to give symbols for another variable called, dead or alive where I want to use square for dead and triangles for alive
How can I create a pca plot showing what I described above? do I need to use something else than gscatter?

採用された回答

Jeff Miller
Jeff Miller 2021 年 12 月 14 日
gscatter will accept multiple grouping variables, in your case organism & dead/alive. There is an example in the gscatter documentation--search for "Scatter Plot with Multiple Grouping Variables". I believe you specify 14 colors and 14 symbols for your 7*2=14 combinations of the two grouping variables.
  4 件のコメント
Kim Arnold
Kim Arnold 2021 年 12 月 16 日
編集済み: Kim Arnold 2021 年 12 月 16 日
Dear jeff,
no worries, you were clear enough. I tried already what you suggested but this did not work correctly.
I finally figured out how it works. If you have like 17 samples and you have 6 groups (my mistake i wrote 7 earlier, but does not really matter regarding this aspect) of organisms which you want to color with 6 colors and then give in addition the symbols dead o and alive * you need first to know if you have in each of the 6 groups dead and alive or only dead or only alive because this makes a difference for the code and is something i did not mention to you when I described my problem. What I did first is the labels of the grouping and then I created
a logical array where 0= dead and 1=alive as [0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0].
Then I merged those two grouping variables as described in the example. Next you define
6 colors for your groups as 'rkkgbcmy'
Then this was the part which was first not clear to me. I went through my 6 groups. first group I had only dead --> symbol o, 2nd group I had dead and alive --> symbols o*, 3rd group only dead--> symbol o, 4th group only alive--> symbol *, 5th group only dead --> symbol o and 6th only dead --> symbol o which gives you an entry for 7 symbols (not 6!) because only in one group you have dead alive and need to specify 2 symbols.
'oo*o*oo'
However, it took a while to figure out, thanks for your input :)
Best,
Kim
Jeff Miller
Jeff Miller 2021 年 12 月 16 日
Hi Kim,
You are welcome. That does sound pretty complicated, so extra-good that you got it working.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDimensionality Reduction and Feature Extraction についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by