필터 지우기
필터 지우기

how i can convert a matrix to a adjacency matrix

조회 수: 2 (최근 30일)
fereshteh izadi
fereshteh izadi 2016년 1월 4일
편집: fereshteh izadi 2016년 1월 4일
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개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by