Error of PWM not colsum to 1 from package DiffLogo or seqLogo
0
1
Entering edit mode
zhxiaokang ▴ 20
@zhxiaokang-13311
Last seen 19 months ago
Norway

I am using the package DiffLogo to plot seqlogo. If I understand correctly, it's like an extension of the package seqLogo. I am using the former one just because it provides the function to take FASTA file and compute the PWM. I got the PWM and confirmed that all the columns' sum is 1. But I still got the compaint that the columns do not sum to 1.

> colSums(pwm)
  1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20
  1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1
 21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40
  1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1
 41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60
  1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1
 61  62  63  64  65  66  67  68  69  70  71  72  73  74  75  76  77  78  79  80
  1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1
 81  82  83  84  85  86  87  88  89  90  91  92  93  94  95  96  97  98  99 100
  1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
  1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1
121
  1
> seqLogo(pwm)
[1] "pwm must be of class matrix or data.frame. Trying to convert"
Error in preconditionPWM(pwm) : Columns of PWM must add up to 1.0
In addition: Warning message:
In matrix(pwm, alphabet$size, length(pwm)/alphabet$size) :
  data length [4961] is not a sub-multiple or multiple of the number of rows [4]

> sessionInfo( )
R version 4.1.3 (2022-03-10)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS:   /home/m320480/.conda/envs/crisprngs/lib/libblas.so.3.9.0
LAPACK: /home/m320480/.conda/envs/crisprngs/lib/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets  methods
[8] base

other attached packages:
[1] DiffLogo_2.18.0 cba_0.2-21      proxy_0.4-27

loaded via a namespace (and not attached):
[1] compiler_4.1.3

I also realized that there is a similar question here: -Inf content in a Position Weight Matrix But the only answer there doesn't help to solve my issue.

seqLogo DiffLogo • 892 views
ADD COMMENT
0
Entering edit mode

We need to have access to the pwm object to help you.

ADD REPLY
0
Entering edit mode

I saved the whole workspace on my Google Drive and it can be downloaded here: workspace on GoogleDrive, and the script is here: script on GoogleDrive

ADD REPLY
0
Entering edit mode

From the warning, looks like you might be starting with a non-base matrix. Try converting first and inspect that object. E.g.,

pwm2 <- as.matrix(pwm)
all(colSums(pwm2) == 1.0)
ADD REPLY
0
Entering edit mode

It seems not helping:

> pwm2 <- as.matrix(pwm)
> all(colSums(pwm2) == 1.0)
[1] TRUE
> seqLogo(pwm2)
[1] "pwm must be of class matrix or data.frame. Trying to convert"
Error in preconditionPWM(pwm) : Columns of PWM must add up to 1.0
In addition: Warning message:
In matrix(pwm, alphabet$size, length(pwm)/alphabet$size) :
  data length [4961] is not a sub-multiple or multiple of the number of rows [4]
ADD REPLY

Login before adding your answer.

Traffic: 846 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6