- 添加路徑+加載數(shù)據(jù)
addpath()
load("XXX.mat")
- 數(shù)據(jù)轉置
df = df'
- 判斷矩陣中全是0的行或列
na=all(isnan(df),2);
z=find(na==1);
all: 當所有元素為0時返回TRUE
- 去掉矩陣某幾個對象
df(z,:)=[]
- 臨近填補
df=knnimpute(df);
- 格式轉換
num2cell %將double轉成cell
cell2mat %將cell轉成double
string %將cell轉成string
str2double %將string轉成double
cellstr %將string 轉成cell
- 查詢某一個元素是否在某一列里面
strcmp(A, B) %查詢B是否在A里
- 查找 (R里面的which)
find(target_met==1)
9 查找 方法2
當C完全是A的子集時,能出C能調出B來
map_1 = containers.Map(A,B);
Metab_name = values(map_1,C);
- 合并矩陣 (相當于R中的cbind, rbind)
cat(1, n, meta) %1是按照行合并
- 創(chuàng)建一組重復數(shù)據(jù)
repmat(6,1,213)
1列,213行,每個數(shù)字都是6
- 輸出圖像
set(gif, "Position", [100 100 700 10000])
print(gif, "-dtiff", "heatmap.png", "-r600")
12.對數(shù)據(jù)進行Z矯正(對列矯正)
data=zscore(data)
- 同一張圖輸出多個圖像
subplot(3,1,1) %一列,3行,第一個圖像
subplot(3,1,2) %一列,3行,第二個圖像
- 在圖像上繼續(xù)加元素
hold on
加完了 hold off
- 制作矩陣(全是0)用于循環(huán)的填充
data = zeros(a,b)
a,b 為行和列
- 查找矩陣有多少行多少列
size(data,1) #多少行
- 查找每列有多少個缺失值
[row,col] = find(isnan(data_mean)==1);
frequency = tabulate(col);
nonan_Meta_Index = find(frequency(:,2)==0);
- 創(chuàng)建路徑
mkdir('result/WTob')
- 創(chuàng)建存儲cell的對象
All_data = cell(6,1); %6行1列
- 一張圖像上畫多個圖
subplot(7,1,i) %7行1列第I個
- 輸出圖像比例
pbaspect([1, 1, 1])
- 字符串連接
strcat(a,b)
- 畫圖參數(shù)
xticks([1:10])
xticklabels(Samplename);
xtickangle(45);
xlabel("log2(Fold change)");
- 新建文件夾
mkdir('result/1')
- 加載數(shù)據(jù)
load()
不等于
~=柱狀圖
histogram(zero_fc,'BinWidth',0.2,'FaceColor','#0072BD')
- 畫虛線
plot([1,1],[0,2500],'--k','LineWidth',1)
- 散點圖
plot(DEGs_red(:,1),-log10(DEGs_red(:,2)),'.','Color',"r")
30 讀取CSV
data_bio = readtable('EC.csv');
data_bio = table2cell(data_bio);