how i can convert a matrix to a adjacency matrix
1 次查看(过去 30 天)
显示 更早的评论
hi, i have below matrix
TFLocus TargetLocus InteractionType
AT5G10140 AT1G65480 -1
AT5G11260 AT1G27480 -1
AT5G11260 AT5G53370 -1
AT5G11260 AT1G03630 -1
AT5G11260 AT1G13600 -1
AT5G11260 AT2G41670 -1
AT5G11260 AT2G05160 -1
AT5G11260 AT2G40170 -1
using the below code from one of member of this website i converted my matrix to an adjacency matrix but the resulted matrix was without column name or rowname while i need these gene IDs as column name and row name in a symmetric matrix then writing the result in a txt file, may some please complete this code for me??? my needed matrix must contain values 0 or 1 please help me kindly thank you the used code fid = fopen('YourFileNameHere.txt', 'rt'); datacell = textscan(fid, '%s%s%d', 'HeaderLines', 1); fclose(fid); TFLocus = datacell{1}; TargetLocus = datacell{2}; all_locus = unique([TFLocus; TargetLocus]); num_locus = length(all_locus); [~, TFidx] = ismember(TFLocus, all_locus); [~, Targidx] = ismember(TargetLocus, all_locus); adj_matrix = accumarray([TFidx(:), Targidx(:)], 1, [num_locus, num_locus]);
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Large Files and Big Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!