how i can convert a matrix to a adjacency matrix

1 visualizzazione (ultimi 30 giorni)
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]);

Risposte (0)

Categorie

Scopri di più su Large Files and Big Data in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by