r - Filteration of 0 counts in all column of metrics and add pseudo counts in remaining columns after filteration? -


I would like to filter the row with correspondence 0 calculations in all the columns of my counting metrics.
Then I want to add some integer to the remaining columns.
The main problem is that I have approximately 36 columns + 1 ID, and Icant wrapped this code that I did for my second column matrix.

  Cat Matrix. Txt | Awk -F "\ t" '{if ($ 2> 0 = $ 3> 0 || $ 4 & gt; $ 5> 0 || $ 6 & gt; 0 || $ 7 & gt; 0) Print $ 1 "\ t" $ 2 + 1 "\ t" $ 3 + 1 "\ t" $ 4 + 1 "\ t" $ 5 + 1 "\ t" $ 6 + 1 "\ T" $ 7 + 1 "\ t"} '& gt; Last_matrix_anenezero_page_cack For Txt  

exp:

  id c1c2c3t1t2t3gene1 0 0 0 0 0 0 gene2 0 0 0 0 0 0 # To remove the shield; Gene 2 rows; All the samples in all the columns are 1 in the gene 3. 1 1 23 45 5 0  

Then add 1 to the remaining matrix (final matrix)

  id c1 c2 c3 t1 t2 t3 gene 1 1 2 1 2 2 3 3 2 2 24 46 6 1   

In R < / Code>, you can

  indx & lt; -! Grepl ("id", colnames (df)) df1 & lt; -df [!! RowSums (df [, index]),] df1 [, indx]  

Data
  df & lt; - Structure (list (id = C ("Gene 1", "Gene 2", "Gene 3"), C1 = C (0L, 0L, 1L), C2 = C (0L, 0L , 1 L), C3 = C (1 L, 0 L, 23 L), T1 = C (0 L, 0 L, 45 L), T2 = C (0 L, 0 L, 5 L ) Name = C ("ID", "C1", "C2", "C3", "T1", "T2", "T3"), class = "data .frame", row. Name = C (NA, -3L))  


Comments